QUE.1 What will be output if you will compile and execute the following c code?
Answer : d
++a +b = 6 + Garbage floating point number = Garbage floating point number // From the rule of automatic type conversion
Hence sizeof operator will return 4 because size of float data type in c is 4 byte. Value of any variable doesn’t modify inside sizeof operator. Hence value of variable a will remain 5.
QUE.2 What will be output if you will compile and execute the following c code?
(a)5 garbage garbage
(b)5 0 0
(c)5 null null
(e)None of above
Answer : b
Explanation: Storage class of an array which initializes the element of the array at the time of declaration is static. Default initial value of static integer is zero.
QUE.3 What will be output if you will compile and execute the following c code?
Answer : e
Explanation: In C, register variable stores in CPU it doesn’t store in RAM. So register variable do nor have any memory address. So it is illegal to write &a.
QUE.4 What will be output if you will compile and execute the following c code?
Answer : c
Explanation: Default storage class of local variable is auto. Scope and visibility of auto variable is within the block in which it has declared. In C, if there are two variables of the same name, then
we can access only local variable. Hence inside the inner block variable a is local variable which has declared and defined inside that block.
When control comes out of the inner block local variable a became dead.
QUE.5 What will be output if you will compile and execute the following C code?
(e)Run time error
Explanation: If you will assign value beyond the range of float data type to the float variable it will not show any compiler error. It will store infinity.
This article is contributed by Ajay Puri(ajay0007). If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please write comments if you find anything incorrect, or you want to share more information about the topic discussed above.