Menu Close

C exam on Control Statements

Please enter your email:

1.

Output of following code?

#include<stdio.h>
int main()
{
  if(1)
  {
    printf("Hello");
    break;
    printf("Hi");
  }
  printf("Bye");
}

 

 
 
 
 

2.

Output of following code?

#include<stdio.h>
int main()
{
  int a=-3, b=-3;
  if(++a=++b)
    printf("%d", a+b);
  else
    printf("%d", a-b);
  return 0;
}

 

 
 
 
 

3.

Output of following code?

#include<stdio.h>
int main()
{
  int a=0 , b=5 ;
  a=b ? printf("Hi") : printf("Hello");
  printf("%d, %d", a, b);
  return 0;
}

 

 
 
 
 

4.

Output of following code?

#include<stdio.h>
int main()
{
  int a=4;
  switch(a)
  {
    printf("a : %d \n", a);
  } 
  return 1;
}

 

 
 
 
 

5.

Output of following code?

#include<stdio.h>
int main()
{
  if(!printf("Hi"))
  printf("Hi");
  printf("Hello");
  return 0;
}

 

 
 
 
 

6.

Output of following code?

#include<stdio.h>
int main()
{
  int i=2;
  switch(i)
  {
    case 1 : printf("Hello ");
    case 2 : printf("Hi ");
    case 3 : continue;
    default: printf("Bye ");
 	}
  return 0;
}

 

 
 
 
 

7.

Output of following code?

#include<stdio.h>
int main()
{
  int i=6;	
  switch(i)
  {
    default	: i+=2;
    case 0	: i=2;
    case 1	: i++;
    case 2	: i+3;
    case 3	: ++i;
        break;	
  }
  printf("i : %d\n",i);
  return 0;
}

 

 
 
 
 

8.

Output of following code?

#include<stdio.h>
int main()
{
    	if(!printf("Live"))
    	if(printf("Tution"));
  return 0;
}

 

 
 
 
 

9.

Output of following code?

#include<stdio.h>
int main()
{
  if(!!0)
  printf("Hi");
  printf("Hello");
  return 0;
}

 

 
 
 
 

10.

Output of following code?

#include<stdio.h>
int main()
{
  int a=0;
  if(a--)
    ++a;
  else
    --a;
  printf("%d", a+a);
  return 0;
}

 

 
 
 
 

Question 1 of 10