Output of C programs | Set 58 (operators) Last Updated : 02 Oct, 2017 Summarize Comments Improve Suggest changes Share Like Article Like Report Prerequisite : Operators in C Q.1 What is the output of this program? CPP #include <iostream> using namespace std; int main() { printf("value is = %d", (10 ++)); return 0; } Options a) 10 b) 11 c) compile time error d) run time error ans: c Explanation : lvalue required as increment operator operate only on variables and not constant values. Q.2 What is the output of this program? CPP #include <iostream> using namespace std; int main() { int i = 0, j = 1, k = 2, m; m = i++ || j++ || k++; printf("%d %d %d %d", m, i, j, k); return 0; } Options a) 1 1 2 3 b) 1 1 2 2 c) 0 1 2 2 d) 1 2 3 3 ans:- b Explanation : Once the value of expression is true in OR, latter expression will not evaluated hence j = 1 is assigned to m . Q.3 What is the output of this program? CPP #include <iostream> using namespace std; int main() { int y = 10; if (y++ > 9 && y++ != 10 && y++ > 11) printf("%d", y); else printf("%d", y); return 0; } Options a) 11 b) 12 c) 13 d) none of above ans: c Explanation : and operator(&) is used so whole expression is evaluated even if the first part is true. Q.4 What is the output of this program? CPP #include <iostream> using namespace std; int main() { int i = 10; i = !i > 14; printf("i=%d", i); return 0; } Options a) i=1 b) i=0 c) i=10 d) none of these ans:- b Explanation : Not oprerator(!) has more precedence than greater than operator(>) so 0>14 is evaluated false. Q.5 What is the output of this program? CPP #include <iostream> using namespace std; int main() { int a = 3, b = 5, c, d; c = a, b; d = (a, b); printf("c=%d d=%d", c, d); return 0; } Options a) c=3 d=5 b) c=5 d=5 c) can't be determined d) none of these ans : a Explanation : The precedence of '(' is greater as compared to ', ' so firstly a is assigned in c and then b is assigned in d. Q.6 What is the output of this program? CPP #include <iostream> using namespace std; int main() { int y = 10; if (y++ > 9 && y++ != 11 && y++ > 11) printf("%d", y); else printf("%d", y); return 0; } Options a) 11 b) 12 c) 13 d) 14 ans: b Explanation : y++!=11 gets false, so y++>11 will not be evaluated. Comment More infoAdvertise with us Next Article Output of C programs | Set 55 (Ternary Operators) P Pragya Singh 2 Improve Article Tags : C Language C-Output C-Operators Similar Reads Output of C programs | Set 53 (Operators) Prerequisite: Operators in C 1. What will be the output of the following? CPP #include <stdio.h> int main(void) { int a; int b = 1; int x[5] = { 1, 2, 3, 4, 5 }; a = 5 * 4 + x[--b] - (9 / b); printf("%d", a); return 0; } Options: 1. 12 2. Abnormal Termination 3. 21 4. No Output The a 2 min read Output of C programs | Set 49 (Operators) Prerequisite : Operators in C 1. What will be the output of the following program? CPP #include <stdio.h> int main(void) { int i = 40 >> 5 << 3 >> 2 << 1; printf("%d", i); return 0; } Options: 1. 4 2. 0 3. 40 4. 1 Answer : (1) Explanation: The answer is option 3 min read Output of C programs | Set 55 (Shift Operators) Prerequisite: Shift operators Q.1 What Is The Output Of this program? C #include <stdio.h> int main() { unsigned int i = 0x80; printf("%d ", i << 1); return 0; } Option a) 0 b) 256 c) 100 d) 80 ans :- b Explanation :- We know that 0x is hexa-decimal representation of number so 3 min read Output of C programs | Set 55 (Ternary Operators) Predict the output of below programs Question 1 C #include <stdio.h> int main() { int x, a = 0; x = sizeof(a++) ? printf("Geeks for Geeks\n") : 0; printf("Value of x:%d\n", x); printf("Value of a:%d", a); return 0; } Output: Geeks for Geeks Value of x:16 Value of 4 min read Output of C programs | Set 8 Predict the output of below C programs. Question 1: c #include<stdio.h> int main() { int x = 5, p = 10; printf("%*d", x, p); getchar(); return 0; } Output: 10 Explanation: Please see standard printf function definition int printf ( const char * format, ... ); format: String that cont 3 min read Output of C Programs | Set 5 Predict the output of below programs Question 1 c int main() { while(1){ if(printf("%d",printf("%d"))) break; else continue; } return 0; } Output: Can't be predictedExplanation: The condition in while loop is 1 so at first shot it looks infinite loop. Then there are break and con 5 min read Like