Assignment 4 : Conditional Statements MCQ
1. What is the output of the following code?
#include <stdio.h>
int main()
{
if(“”)
printf(“Sudhakar”);
else
printf(“Welcome”);
}
2. Observe the output of the following code.
#include <stdio.h>
int main()
{
if(;) // semicolon inside if; hint : gives an error
printf(“Sudhakar”);
else
printf(“Welcome”);
}
3. What is the output of the following code?
int main(void)
{
if (10.2) /* floating point constant */
printf(“Hello Sudhakar”);
if (0.0) /* floating point constant */
printf(“Hello Sudhakar”);
return 0;
}
8. What is the output of the following code?
#include <stdio.h>
int main()
{
char c=65;
if (c==’A’)
printf(“Vowel”);
else
printf(“Not vowel”);
return 0;
}
9. What is the output of the following code?
#include <stdio.h>
int main()
{
char c=66;
if (c==’A’)
printf(“Vowel”);
else
printf(“Not vowel”);
return 0;
}
#include <stdio.h>
void main()
{
int x = 5;
if (true);
printf(“hello”);
}11. What is the output of the following code?
#include <stdio.h>
int main()
{
int x = 0;
if (x == 1)
if (x >= 0)
printf(“true\n”);
else
printf(“false\n”);
return 0;
}
12. What is the output of the following code?
#include<stdio.h>
int main()
{
int a = 1;
if (a–)
printf(“True”);
if (a++)
printf(“False”);
return 0;
}
13. What is the output of the following code?
#include <stdio.h>
int main()
{
int x = 0;
if (x == 1)
if (x == 0)
printf(“I am IF\n”);
else
printf(“I am Inside ELSE\n”);
else
printf(“I am outside else\n”);
}
14. What is the output of the following code?
int main()
{
int a = 1;
if (a)
printf(“I am Sudhakar “);
printf(“I am Kaivalya\n”);
else
printf(“I am akshaya\n”);
}
15. What is the output of the following code?
#include<stdio.h>
int main()
{
if (printf(“%d”, printf(“sudhakar”)))
printf(“I am Executed”);
else if (printf(“1”))
printf(“I am not executed”);
}