[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

5 / 51

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

#include<stdio.h>
int main(){
    float x;
    x=(int)5.6f*3.2f/sizeof((int)6.6);
    printf("%f",x);
    return 0;
}

A8.96

B9.6

C8

D2

ECompilation error

Answer: Option (Login/Signup)

Show Explanation

In line 4-

x=(int)5.6f*3.2f/sizeof((int)6.6);

or, x=(int)5.6f*3.2f/sizeof(6);        [Since, we are typecasting 6.6 to int]

or, x=(int)5.6f*3.2f/4;                    [Since, 6 is integer type, and size of int is 4 bytes]

or, x=(int)4.48;

or, x=4;                                         [Since, 4.48 is typecasted to int]

In line 5, we are converting int x=4 to float type and we are printing it.

Hence, the output is 4.000000.

Asked In ::

Post Your Answer Here:     

Reply    
Rate This: +0 -0
    Report


Report Error

Please Login First Click Here