Expressions - Find Output of Program :: Discussion


5.What will be the output of the program?
A.1, 1, 1, 1
B.1, 1, 0, 1
C.1, 0, 0, 1
D.1, 0, 1, 1
Answer:  Option  D
Explanation:

Step 1int i=4, j=-1, k=0, w, x, y, z; here variable i, j, k, w, x, y, z are declared as an integer type and the variable i, j, k are initialized to 4, -1, 0 respectively.

Step 2w = i || j || k; becomes w = 4 || -1 || 0;. Hence it returns TRUE. So, w=1

Step 3x = i && j && k; becomes x = 4 && -1 && 0; Hence it returns FALSE. So, x=0

Step 4y = i || j &&k; becomes y = 4 || -1 && 0; Hence it returns TRUE. So, y=1

Step 5z = i && j || k; becomes z = 4 && -1 || 0; Hence it returns TRUE. So, z=1.

Step 6printf("%d, %d, %d, %d\n", w, x, y, z); Hence the output is "1, 0, 1, 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