Vidyalelo
C Programming · all questions

Control Structures
practice.

Practice every MCQ with options. Use Show answers when you want the correct option and solution.

155

Questions

2/8

Page

Pick an option on a question to see the right answer and solution.

Which control structure is used to execute a block of code repeatedly as long as a condition is true in C?

Select an option to see the answer and solution.

What is the purpose of the 'switch' statement in C?

Select an option to see the answer and solution.

What is the result of the expression `3 || 0` in C?

Select an option to see the answer and solution.

In C, which control structure is used to execute a block of code a specific number of times?

Select an option to see the answer and solution.

What happens if a 'break' statement is used within a 'switch' statement in C?

Select an option to see the answer and solution.

What is the result of the expression !0 in C?

Select an option to see the answer and solution.

Which control structure is used to execute a block of code only if a condition is true in C?

Select an option to see the answer and solution.

What is the purpose of the 'return' statement in C?

Select an option to see the answer and solution.

In C, which control structure allows you to define a block of code to be executed in response to a specific event or condition?

Select an option to see the answer and solution.

What is the result of the expression 1 && 1 in C?

Select an option to see the answer and solution.

What is the output of given program if user enter value 99?
#include<stdio.h>
void main()
{
	int i;
	printf("Enter a number:");
	scanf("%d", &i); // 99 is given as input.
	if(i%5 == 0){
		printf("nNumber entered is divisible by 5");
        }
}

Select an option to see the answer and solution.

What is the output of given program if user enter "xyz" ?
#include<stdio.h>
void main()
{
	float age, AgeInSeconds;
	printf("Enter your age:");
	scanf("%f", &age);
	AgeInSeconds = 365 * 24 * 60 * 60 * age;
	printf("You have lived for %f seconds", AgeInSeconds);
}

Select an option to see the answer and solution.

What is the output of given program if user enter "xyz" ?
#include<stdio.h>
void main()
{
	float age, AgeInSeconds;
	int value;
	printf("Enter your age:");
	value=scanf("%f", &age);
	if(value==0){
		printf("\\nYour age is not valid");
	}
	AgeInSeconds = 365 * 24 * 60 * 60 * age;
	printf("\\n You have lived for %f seconds", AgeInSeconds);
}

Select an option to see the answer and solution.

What will be the output of the given program?
#include<stdio.h>
void main()
{
      int  i=10;
      printf("i=%d", i);
      {
            int  i=20;
	    printf("i=%d", i);
	    i++;
	    printf("i=%d", i);
      }
      printf("i=%d", i);
}

Select an option to see the answer and solution.

What will be the value of i and j after execution of following program?
#include<stdio.h>
void main()
{
	int i, j;
	for(i=0,j=0;i<10,j<20;i++,j++){
		printf("i=%d %t j=%d", i, j);
       }
}

Select an option to see the answer and solution.

What will be the output given program?
#include<stdio.h>
void main()
{
	int i = -10;
	for(;i;printf("%d ", i++));
}

Select an option to see the answer and solution.

What will be the output of the given program?
#include<stdio.h>
void main()
{
	int a=11,b=5;
	if(a=5) b++;
	printf("%d %d", ++a, b++);
}

Select an option to see the answer and solution.

What will be the output of the given program?
#include<stdio.h>
void main()
{
      int value=0;
      if(value)
            printf("well done ");
      printf("examveda");
}

Select an option to see the answer and solution.

What will be the output of the given program?
#include<stdio.h>
void main()
{
	int value1, value2=100, num=100;
	if(value1=value2%5) num=5;
	printf("%d %d %d", num, value1, value2);
}

Select an option to see the answer and solution.

What will be the output of the given program?
#include<stdio.h>
void main()
{
	float num=5.6;
	switch(num){
		case 5:printf("5");
		case 6:printf("6");
		default : printf("0");
			break;

	}
	printf("%d", num);
}

Select an option to see the answer and solution.