Functions - Find Output of Program :: Discussion


8.What will be the output of the program?
A.8
B.9
C.10
D.11
Answer:  Option  B
Explanation:

Step 1int fun(int); Here we declare the prototype of the function fun().

Step 2int i = fun(10); The variable i is declared as an integer type and the result of the fun(10) will be stored in the variable i.

Step 3int fun(int i){ return (i++); } Inside the fun() we are returning a value return(i++). It returns 10. because i++ is the post-increement operator.

Step 4: Then the control back to the main function and the value 10 is assigned to variable i.

Step 5printf("%d\n", --i); Here --i denoted pre-increement. Hence it prints the value 9.

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