Comment on the following expression? c = (n) ? a : b; can be rewritten as
1.if (!n)c = b; else c = a
2.if (n <= 0)c = b; else c = a
3. if (n > 0)c = a; else c = b;
4.All of the mentioned
Comment on the output of this C code? void main() { int k = 8; int m = 7; int z = k < m ? k = m : m++; printf("%d", z); }
1.Run time error
2.7
3.8
4.Depends on compiler
For initialization a = 2, c = 1 the value of a and c after this code will be c = (c) ? a = 0 : 2;
1.a = 0, c = 0;
2.a = 2, c = 2;
3.a = 2, c = 2
4. a = 1, c = 2;
The code snippet below produces void main() { 1 < 2 ? return 1 : return 2; }
1.returns 1
2.returns 2
3.varies
4.Compile time error
The output of the code below is void main() { int k = 8; int m = 7; k < m ? k = k + 1 : m = m + 1; printf("%d", k); }
1.Compile time error
2.9
3.8
4.Run time error
The output of the code below is void main() { int k = 8; int m = 7; k < m ? k++ : m = k; printf("%d", k); }
1.7
2.8
3.Compile time error
4.Run time error
Value of c after the following expression (initializations a = 1, b = 2, c = 1): c += (-c) ? a : b;
1.syntax error
2.c = 1
3.c = 2
4.c = 3
What is the output of this C code? int main() { int a = 2; int b = 0; int y = (b == 0) ? a :(a > b) ? (b = 1): a; printf("%d ", y); }
1.Compile time error
2.1
3.2
4.Undefined behaviour
What is the output of this C code? int main() { int x = 1; int y = x == 1 ? getchar(): 2; printf("%d ", y); }
1.Compile time error
2.Whatever character getchar function returns
3.Ascii value of character getchar function returns
4.2
What is the output of this C code? int main() { int x = 1; short int i = 2; float f = 3; if (sizeof((x == 2) ? f : i) == sizeof(float)) printf("float "); else if (sizeof((x == 2) ? f : i) == sizeof(short int)) printf("short int "); }
1.float
2.short int
3.Undefined behaviour
4.Compile time error
What is the output of this C code? int main() { int x = 2, y = 0; int z = (y++) ? y == 1 && x : 0; printf("%d ", z); return 0; }
1.0
2.1
3.Undefined behavior
4.Compile time error
What is the output of this C code? int main() { int y = 1, x = 0; int l = (y++, x++) ? y : x; printf("%d ", l); }
1.1
2.2
3.Compile time error
4.Undefined behaviour
What is the output of this C code? void main() { int k = 8; int m = 7; int z = k < m ? k++ : m++; printf("%d", z); }
1.7
2.8
3.Run time error
4.None of the mentioned.
What will be the data type of the expression (a < 50) ? var1 : var2; provided a = int, var1 = double, var2 = float
1.float
2.int
3.double
4.Cannot be determined
Which expression has to be present in the following? exp1 ? exp2 : exp3;
1.exp1
2.exp2
3.exp3
4.All of the mentioned