Decision Making
- Which of the following statements are correct about the program given below?
#include <stdio.h>
int main ( )
{
int a = 0, b = 1;
b == 1 ? (a = 0) : (a = 1);
if (a)
printf ("YES\n");
else
printf ("No\n");
return 0;
}
-
View Hint View Answer Discuss in Forum
The program works correctly without error.
Correct Option: E
The program works correctly without error.
- Which of the following is the correct output for the program given below?
#include <stdio.h>
int main ( )
{
int a = 5;
float b = 5.0;
if (a == b)
printf (" a and b are equal\n");
else
printf ("a and b are not equal\n");
return 0;
}
-
View Hint View Answer Discuss in Forum
During comparison a would get promoted
Correct Option: A
During comparison a would get promoted to a float and then two floats would be compared.
- Which of the following statements are correct about the following program?
#include <stdio.h>
int main ( )
{
int a = 20, b = 30;
if (a % 2 = b % 3)
printf ("\n Carpathians");
return 0;
}
-
View Hint View Answer Discuss in Forum
= must have L value
Correct Option: B
= must have L value
Error : 'L value required'