Wednesday, 28 February 2018

C interview question 8

What will be the output of the given code?

#include <stdio.h>

int main(void) {
 
 float a = 3.14;
 
 printf("%f",a%3);
 
 return 0;
}

Ans: Error


Reason: 
The modulus operator requires int type of data for it's operation.
Here we are giving one float data and other is integer data so the output will be an error.

No comments:

Post a Comment

C interview question 8

What will be the output of the given code? #include <stdio.h> int main(void) { float a = 3.14; printf("%f",a%3); ...