VOOZH about

URL: https://www.geeksforgeeks.org/c/output-c-programs-set-47-decision-control-statements/

⇱ Output of C programs | Set 47 (Decision and Control Statements) - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

Output of C programs | Set 47 (Decision and Control Statements)

Last Updated : 30 Sep, 2024

Decision and Loops & Control Statements

QUE.1 What is the output of this program ?

OPTION

a) geeks b) infinite time geeks c) Compile time error d) No Output

Answer: b

Explanation:

printf returns the number of characters of "geeks". It returns 5 and loop runs infinite times because 5>0 and it is neither increasing nor decreasing. So it will print "geeks" infinite times

QUE.2 What is the output of this program?

OPTION

a) geeks b) infinite time geeks c) compile time error d) no output

Answer: a

Explanation:

printf returns the number of characters "geeks". It will return 5 but when it enters int, the body of loop it will get "return 0" and terminates the program so it will print "geeks" only one time.

QUE. 3 What is the output of this program ?

OPTION

a) geeks b) for c) geeksfor d) geeksforgeeks

Answer: c

Explanation:

if, switch and while are condition checkers in his () and print anything written in his (). In this program, first run if() and printf return "geeks" 5 and come to 2 switch. Now switch print "for" and printf return 3 and now switch find case 3 and case 3 is not in the program and it terminates the program and print only "geeksfor".

QUE.4 What is the output?

OPTION

a) geeks b) geeksforgeeks c) geeksgeeksforgeeks d) Compile Errors

Answer: c

Explanation:

First time, the if block is checked after printing geeks. Then check condition if(printf("geeks")!=5). Here condition is false then go to else part and print "geeksforgeeks" also. Then, go to the else part and print then output is geeksgeeksforgeeks.

QUE.5 What is output of this program?

OPTION

a) geeks b) 10 c) geeks 10 d) Compile Errors

Answer: d

Explanation:

Error: Invalid Initialization You cannot define a printf as a int n=printf(). The data definition has no type or storage class.

Related Article :

Quiz on Loop and Control structures
Comment
Article Tags:
Article Tags: