0% found this document useful (0 votes)
18 views

C If Else (Conditional Statements)

Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
18 views

C If Else (Conditional Statements)

Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 5

1) What will be the output of following program ?

1 #include <stdio.h>
2 void main()
3 {
4 if(!printf(""))
5 printf("Okkk");
6 else
7 printf("Hiii");
8 }

1. Okkk
2. Hiii
3. Error
4. None

Answer

2) What will be the output of following program ?

1 #include <stdio.h>
2 void main()
3 {
4 int x=22;
5 if(x=10)
6 printf("TRUE");
7 else
8 printf("FALSE");
9 }

1. TRUE
2. FALSE
3. Error
4. None

Answer

3) What will be the output of following program ?

1 #include <stdio.h>
2 void main()
3 {
4 char val=1;
5 if(val--==0)
6 printf("TRUE");
7 else
8 printf("FALSE");
9 }

1. FALSE
/
2. Error
3. TRUE
4. None

Answer

4) What will be the output of following program ?

1 #include <stdio.h>
2 void main()
3 {
4 float a=10.5;
5
6 printf("\n===FIRST CONDITION\n");
7 if(sizeof(a)==sizeof(10.5))
8 printf("Matched !!!");
9 else
10 printf("Not matched !!!");
11
12 printf("\n===SECOND CONDITION\n");
13 if(sizeof(a)==sizeof(10.5f))
14 printf("Matched !!!");
15 else
16 printf("Not matched !!!");
17
18 printf("\n===THIRD CONDITION\n");
19 if(sizeof((double)a)==sizeof(10.5))
20 printf("Matched !!!");
21 else
22 printf("Not matched !!!");
23
24 printf("\n===FOURTH CONDITION\n");
25 if(a==10.5f)
26 printf("Matched !!!");
27 else
28 printf("Not matched !!!");
29
30 printf("\n");
31 }

Answer

5) What will be the output of following program ?

1 #include <stdio.h>
2 int main()
3 {
4 int a=10;
5 if(a==10)
6 {
7 printf("Hello...");
8 break; /
9 printf("Ok");
10 }
11 else
12 {
13 printf("Hii");
14 }
15 return 0;
16 }

1. Hello...
2. Hello...OK
3. OK
4. Error

Answer

6) What will be the output of following program ?

1 #include <stdio.h>
2 int main()
3 {
4 if( (-100 && 100)||(20 && -20) )
5 printf("%s","Condition is true.");
6 else
7 printf("%s","Condition is false.");
8 return 0;
9 }

1. Condition is true.
2. Condition is false.
3. No output
4. ERROR

Answer

7) What will be the output of following program ?

1 #include <stdio.h>
2 #define TRUE 1
3 int main()
4 {
5 if(TRUE)
6 printf("1");
7 printf("2");
8 else
9 printf("3");
10 printf("4");
11 return 0;
12 }
/
1. ERROR
2. 1
3. 12
4. 2

Answer

8) What will be the output of following program ?

1 #include <stdio.h>
2 int main()
3 {
4 int pn=100;
5 if(pn>20)
6 if(pn<20)
7 printf("Heyyyyy");
8 else
9 printf("Hiiiii");
10 return 0;
11 }

1. No output
2. Hiiiii
3. Heyyyyy
4. HeyyyyyHiiiii

Answer

9) Which of the following are incorrect statements? If int a=10.

1 1) if( a==10 ) printf("IncludeHelp");


2 2) if( 10==a ) printf("IncludeHelp");
3 3) if( a=10 ) printf("IncludeHelp");
4 4) if( 10=a ) printf("IncludeHelp");

1. 3 and 4.
2. 3 only.
3. 4 only.
4. 2,3 and 4.

Answer

10) What will be the output of following program ?

1 #include <stdio.h>
2 int main()
/
3 {
4 int a=10;
5 if(10L == a)
6 printf("10L");
7 else if(10==a)
8 printf("10");
9 else
10 printf("0");
11 return 0;
12 }

1. 10.
2. 10L.
3. 10L10.
4. ERROR.

You might also like