[Updated] Goldman Sachs Aptitude Test Questions and Answers
Practice List of TCS Digital Coding Questions !!!
Take 50+ FREE!! Online Data Interpretation Mock test to crack any Exams.

C Programming :: Variables & Data Types - Discussion

Home > C Programming > Variables & Data Types > MCQs Questions Discussion

33 / 51

What will be output of the following "c" code?

#include<stdio.h>
void main(){
   float a=5.2;
  if(a==5.2)
     printf("Equal");
  else if(a<5.2)
     printf("Less than");
  else
     printf("Greater than");
}

AEqual

BGreater than

CLess than

DCompilation Error

Answer: Option (Login/Signup)

Show Explanation

5.2 is a double-type constant in C. In C, size of double-type data is 8 bytes while variable 'a' is of float-type. Size of float variable is 4 bytes.
So, double-type constant, i.e, 5.2 is stored in the memory as-
101.00 11001100 11001100 11001100 11001100 11001100 11001101
On the other hand, content of variable 'a' will be stored in the memory as-
101.00110 01100110 01100110
It is clear that variable 'a' is less than the double-type constant 5.2.
Hence, the output is Less than.

Asked In ::

Post Your Answer Here:     

Reply    
Rate This: +0 -0
    Report


Report Error

Please Login First Click Here