Declarations and Initializations - Point Out Correct Statements :: Discussion


2.Which of the following operations are INCORRECT?
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
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.

Tutorial Link:
Published by:Michael Daani

Comments are not available

Post your comments here:

Optional

Date to Date Current Affairs 2022

PakMCQs.net

Quick Links

GAT Subject



   Computer Science    English Mcqs    Agriculture    

Engineering



   Computer Science    Civil Engineering    

Technical



   Networking    Electronics    Database    

Past Papers



   Model Papers    FPSC Papers