Functions - Find Output of Program :: Discussion


11.What will be the output of the program?
A.prints "Pak-Mcqs, C-Program" infinitely
B.prints "C-Program" infinetly
C.prints "C-Program, Pak-Mcqs" infinitely
D.Error: main() should not inside else statement
Answer:  Option  B
Explanation:

Step 1int i=1; The variable i is declared as an integer type and initialized to 1(one).

Step 2if(!i) Here the !(NOT) operator reverts the i value 1 to 0. Hence the if(0) condition fails. So it goes to else part.

Step 3else { i=0; In the else part variable i is assigned to value 0(zero).

Step 4printf("C-Program"); It prints the "C-program".

Step 5main(); Here we are calling the main() function.

After calling the function, the program repeats from step 1 to step 5 infinitely.

Hence it prints "C-Program" infinitely.

Tutorial Link:
Published by:Michael Daani

Comments are not available

Post your comments here:

Optional

Date to Date Current Affairs 2022

PakMCQs.net

Quick Links

GAT Subject



   Computer Science    English Mcqs    Agriculture    

Engineering



   Computer Science    Civil Engineering    

Technical



   Networking    Electronics    Database    

Past Papers



   Model Papers    FPSC Papers