VOOZH about

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

⇱ Output of C programs | Set 34 - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

Output of C programs | Set 34

Last Updated : 8 Jul, 2017
Ques 1. Assume that the size of an integer is 4 bytes and size of character is 1 byte. What will be the output of following program? options : A)12 B)16 C)8 D)4
Answer - C
Explanation : In union data type, the memory required to store a union variable is the memory required for the largest element of an union. Ques 2. What will be the output of following program? options : A)9 7 5 3 1 B)9 8 7 6 5 4 3 2 1 C)Infinite loop D)9 7 5 3
Answer - C
Explanation : The loop will run infinite time because n will never be equal to 0. Ques 3. What will be the output of following program? Options : A)Geeks B)runtime error C)Geeksforgeeks D)compile time error
Answer - C
Explanation : Here we are assigning(=) and not comparing(==) x with 0 which is not true so the else part will execute and print Geeksforgeeks. Ques 4.What will be output of following c code? Options : A)1 B)2 C)0 D)No output
Answer : A
Explanation: Consider the while loop condition:
i + 1 ? -- i : ++j
In first iteration: i + 1 = 3 (True), So ternary operator will return
 -–i i.e. 1
In C, 1 means true so while condition is true. Hence printf statement will print 1 In second iteration: i + 1 = 2 (True), So ternary operator will return
-–i i.e. 0
In C, zero means false so while condition is false. Hence program control will come out of the while loop. Ques 5. Assume that the size of an integer is 4 bytes and size of character is 1 byte. What will be the output of following program?
options : A)12 B)16 C)8 D)4
Answer - B
Explanation : In structure data type, The amount of memory required to store a structure variable is the sum of memory size of all members.
Comment
Article Tags:
Article Tags: