Sail E0 Webinar

MCQs

Total Questions : 15 | Page 1 of 2 pages
Question 1. What is the output of this C code?
int main()
{
int x = 2, y = 0;
int z = (y++) ? y == 1 && x : 0;
printf("%d\n", z);
return 0;
}
  1.    0
  2.    1
  3.    Undefined behavior
  4.    Compile time error
 Discuss Question
Answer: Option A. -> 0


None.


Question 2. 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\n", y);
}
  1.    Compile time error
  2.    1
  3.    2
  4.    Undefined behaviour
 Discuss Question
Answer: Option C. -> 2


None.


Question 3. 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\n");
else if (sizeof((x == 2) ? f : i) == sizeof(short int))
printf("short int\n");
}
  1.    float
  2.    short int
  3.    Undefined behaviour
  4.    Compile time error
 Discuss Question
Answer: Option A. -> float


None.


Question 4. What is the output of this C code?
int main()
{
int x = 1;
int y = x == 1 ? getchar(): 2;
printf("%d\n", y);
}
  1.    Compile time error
  2.    Whatever character getchar function returns
  3.    Ascii value of character getchar function returns
  4.    2
 Discuss Question
Answer: Option C. -> Ascii value of character getchar function returns


None.


Question 5. What is the output of this C code?
int main()
{
int y = 1, x = 0;
int l = (y++, x++) ? y : x;
printf("%d\n", l);
}
  1.    1
  2.    2
  3.    Compile time error
  4.    Undefined behaviour
 Discuss Question
Answer: Option A. -> 1


None.


Question 6. 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.
 Discuss Question
Answer: Option A. -> 7


None.


Question 7. 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
 Discuss Question
Answer: Option B. -> 7


None.


Question 8. 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
 Discuss Question
Answer: Option C. -> Compile time error


None.


Question 9. 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
 Discuss Question
Answer: Option D. -> Compile time error


None.


Question 10. 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
 Discuss Question
Answer: Option A. -> Compile time error


None.


Latest Videos

Latest Test Papers