VOOZH about

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

⇱ Output of C programs | Set 42 - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

Output of C programs | Set 42

Last Updated : 29 Oct, 2021

QUE.1 What is the output of following program? 

a. 10 10 10 
b. 100xaa54f10 
c. Run time error 
d. No Output 

Answer : a


Explanation: Because y contains the address of x so *y print 10 then **z contains address of y of x so print the value of x 10 and 3rd *(*z) contains address of y of x that's why print 10. So, final output is 10 10 10.

QUE.2 What is the output of following program? 

a) 25 
b) 50 
c) 12 
d) 4 

Answer : d


Explanation: Here, do while loop executes once and then it will check condition while will be false meanwhile value will be increased 3 times (two times in do while body and once while checking the condition); 
Hence value will be 4.

QUE.3 What is the output of following program in the text file?  

a) enter in the if 
b) not entered 
c) run time error 
d) segmentation fault 

Answer : b


Explanation: In this program, We are check the if condition all (a, b, c)>0 but d = 0 so condition is false didn't enter in the if so print not entered.

QUE.4 What is the output of following program?  

a) 5, 10 
b) 10, 5 
c) 10, 20 
d) None of the mentioned 

Answer: a


Explanation: strlen gives length of the string that is 5; sizeof gives total number of occupied memory for a variable that is 8; since str is a pointer so sizeof(str) may be 2, 4 or 8. 
It depends on the computer architecture.

QUE.5 What is the output of following program?  

OPTION 
a) Hi 
b) HelloHi 
c) run time error 
d) None of the mentioned 

Answer : b

Explanation: There is a semicolon after the if statement, so this statement will be considered as a separate statement; and here printf("Hello"); will not be associated with the if statement. Both printf statements will be executed.


 

Comment
Article Tags:
Article Tags: