Sail E0 Webinar
Question

Which of the following operations are INCORRECT?


Options:
A .  int i = 35; i = i%5;
B .  short int j = 255; j = j;
C .  long int k = 365L; k = k;
D .  float a = 3.14; a = a%3;
Answer: Option D

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.




Was this answer helpful ?
Next Question

Submit Solution

Your email address will not be published. Required fields are marked *

Latest Videos

Latest Test Papers