Expressions - Find Output of Program :: Discussion


3.What will be the output of the program?
A.z=2
B.z=4
C.z=1
D.z=0
Answer:  Option  C
Explanation:

Step 1int x=12, y=7, z; here variable x, y and z are declared as an integer and variable x and y are initialized to 12, 7 respectively.

Step 2z = x!=4 || y == 2;
becomes z = 12!=4 || 7 == 2;
then z = (condition true) || (condition false); Hence it returns 1. So the value of z=1.

Step 3printf("z=%d\n", z); Hence the output of the program is "z=1".

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