VOOZH about

URL: https://www.geeksforgeeks.org/c/output-c-programs-set-41/

⇱ Output of C programs | Set 41 - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

Output of C programs | Set 41

Last Updated : 23 Aug, 2017
QUE.1 What will be output if you will compile and execute the following c code? (a)2 6 (b)4 6 (c)2 5 (d)4 5
Answer : d
Explanation:
 ++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 (d)Compiler error (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? (a)17 (b)18 (c)21 (d)22 (e)Compiler error
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? OPTION (a)5 10 (b)6 11 (c)5 11 (d)6 10 (e)Compiler error
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?
OPTION (a)3.4e39 (b)3.40000… (c)inf (d)Compiler error (e)Run time error
Answer: c 
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.
Comment
Article Tags:
Article Tags: