C Language MCQ’S | Control Instructions 8

36.
Which of the following statements are correct about the below program?

#include<stdio.h>
int main()
{
int i = 10, j = 20;
if(i = 5) && if(j = 10)
printf(“Have a nice day”);
return 0;
}

A. Output: Have a nice day
B. No output
C. Error: Expression syntax
D. Error: Undeclared identifier if

 

37.
Which of the following statements are correct about the below program?

#include<stdio.h>
int main()
{
int i = 10, j = 15;
if(i % 2 = j % 3)
printf(“Catalyst\n”);
return 0;
}

A. Error: Expression syntax
B. Error: Lvalue required
C. Error: Rvalue required
D. The Code runs successfully

 

38.
Which of the following statements are correct about the program?

#include<stdio.h>
int main()
{
int x = 30, y = 40;
if(x == y)
printf(“x is equal to y\n”);

else if(x > y)
printf(“x is greater than y\n”);

else if(x < y)
printf(“x is less than y\n”)
return 0;
}

A. Error: Statement missing
B. Error: Expression syntax
C. Error: Lvalue required
D. Error: Rvalue required

39.
Which of the following statements are correct about an if-else statements in a C-program?

1: Every if-else statement can be replaced by an equivalent statements using ?: operators
2: Nested if-else statements are allowed.
3: Multiple statements in an if block are allowed.
4: Multiple statements in an else block are allowed.

A. 1 and 2
B. 2 and 3
C. 1, 2 and 4
D. 2, 3, 4

 

40.
Which of the following statements are correct about the below program?

#include<stdio.h>
int main()
{
int i = 0;
i++;
if(i <= 5)
{
printf(“Catalyst\n”);
exit(0);
main();
}
return 0;
}

A. The program prints ‘Catalyst’ 5 times
B. The program prints ‘Catalyst’ one time
C. The call to main() after exit() doesn’t materialize.
D. The compiler reports an error since main() cannot call itself.