MCQ PRACTICE QUESTIONS

1.what will be the output of the following C code?

#include<stdio.h>

void main()

{

  for(int i=0; i<1; i++)

  printf(“in for loop\n”);

}

1.       Run time error

2.       Compile time error

3.       In for loop

4.       Depends on the standerd compiler imlements

2.what will be the output of the following C code?

#include<stdio.h>

void main()

{

  int *p=NULL;

  for(foo(); p; p=0)

  printf(“in for loop\n”);

  printf(“after loop”);

}  

1.       Compile time error

2.       In for loop after loop

3.       Depends on the value of null

4.        Infinte loop

3.what will be the output of the following C code?

#include<stdio.h>

void main()

{

  int i=0;

  for(i++; i==1; i=2)

  printf(“in for loop\n”);

  printf(“after loop”);

}

1.       Undefined behaviour

2.       In for loop after loop

3.       In for loop

4.       Compile time error

4.what will be the output of the following C code?

#include<stdio.h>

void main()

{

  for(int i=-3; i<-5; i++)

  printf(“hello”);

1.       Hello

2.       Infinite hello

3.       Run time error

4.       Nothing

5.what will be the output of the following C code?

#include<stdio.h>

void main()

{

  for(int i=0; i<1; i++)

  printf(“in for loop\n”);

}