If Statement Quiz

Best of Luck


Question 1.

Find the output of the given program.

#include<stdio.h>

 int main() 

{ 

if(0)

 { printf("a"); 

} 

printf("b"); 

printf("c"); 

return 0;

 }
  • A) abc
  • B) Compile time error
  • C) bc
Question 2.

 What will be the value of y if x = 9?

 

y = (x  > 7 ? 5 : 7);
  • A) Compilation Error
  • B) 0
  • C) 5
  • D) 7
Question 3.

Find the output of the given C program.

#include<stdio.h> 

int main() {

 int k; 

k = 0, 1; 

if(k) { 

printf("a"); 

printf("b");

 }

 printf("c"); 

return 0;

 }
  • A) Compile time error
  • B) c
  • C) ab
  • D) abc
Question 4.

Find the output of the given C program.

#include<stdio.h>

 int main() { 

if("false") { 

printf("a"); 

printf("b");

 } 

printf("c"); 

return 0; 

}
  • A) c
  • B) Compile time error
  • C) ab
  • D) abc
Question 5.

Find the output of the given C program.

#include<stdio.h>

 int main() {

 if(0) { 

printf("a"); 

printf("b"); 

} 

printf("c"); 

return 0; 

}
  • A) c
  • B) abc
  • C) Compile time error
  • D) ab
Question 6.

Find the output of the given C program.

#include<stdio.h> 

int main() {

 int k = 0, 1;

 if(k) { 

printf("l"); 

printf("m");

 } 

printf("n");

 return 0;

 }
  • A) lm
  • B) Compile time error
  • C) lmn
  • D) n
Question 7.

Find the output of the given C program.

#include<stdio.h> 

int main() { 

if() { 

printf("a"); 

printf("b"); 

} 

printf("c"); 

return 0; 

}
  • A) abc
  • B) c
  • C) Compile-time error
  • D) ab
Question 8.

Find the output of the given C program.

#include<stdio.h> 

int main() { 

int x; 

x = (0, 1); 

if(x) { 

printf("i); 

printf("j"); } 

printf("k"); 

return 0; 

}
  • A) Compile-time error
  • B) k
  • C) ij
  • D) ijk
Question 9.

Find the output of the given C program.

#include<stdio.h>

 int main() {

 if("") {

 printf("i");

 printf("j"); 

} 

printf("k"); 

return 0;

 }
  • A) ij
  • B) k
  • C) ijk
  • D) Compile-time error
Question 10.

Find the output of the given C program.

#include<stdio.h> 

int main() {

 int i=0; 

if(i++) { 

printf("a"); 

printf("b"); 

}

 printf("c");

 return 0; 

}
  • A) c
  • B) Compile time error
  • C) abc
  • D) ab