Home » C Programming » Declarations and Initializations

Which of the following operations are INCORRECT?

Correct Answer: float a = 3.14; a = a%3;

Explanation:

float a = 3.14; a = a%3; gives "Illegal use of floating point" error.


The modulus (%) operator can only be used on integer types. We have to use fmod() function in math.h for float values.


← Previous Question Next Question→

Discussion & Comments

No comments yet. Be the first to comment!
Join Discussion