C If else - Aptitude Questions & Answers

C programming if else Aptitude Questions and Answers: In this section you will find C Aptitude Questions and Answers on condition statements – if else, nested if else, ladder if else, conditional operators etc.

1) What will be the output of following program ?
#include <stdio.h>
void main()
{
	if(!printf(""))
		printf("Okkk");
	else
		printf("Hiii");
}
        
  1. Okkk
  2. Hiii
  3. Error
  4. None

2) What will be the output of following program ?
#include <stdio.h>
void main()
{
	int x=22;
	if(x=10)
		printf("TRUE");
	else
		printf("FALSE");
}
        
  1. TRUE
  2. FALSE
  3. Error
  4. None

3) What will be the output of following program ?
#include <stdio.h>
void main()
{
	char val=1;
	if(val--==0)
		printf("TRUE");
	else
		printf("FALSE");
}
        
  1. FALSE
  2. Error
  3. TRUE
  4. None


4) What will be the output of following program ?
#include <stdio.h>
void main()
{
	float a=10.5;

	printf("\n===FIRST CONDITION\n");
	if(sizeof(a)==sizeof(10.5))
		printf("Matched !!!");
	else
		printf("Not matched !!!");

	printf("\n===SECOND CONDITION\n");
	if(sizeof(a)==sizeof(10.5f))
		printf("Matched !!!");
	else
		printf("Not matched !!!");

	printf("\n===THIRD CONDITION\n");
	if(sizeof((double)a)==sizeof(10.5))
		printf("Matched !!!");
	else
		printf("Not matched !!!");

	printf("\n===FOURTH CONDITION\n");
	if(a==10.5f)
		printf("Matched !!!");
	else
		printf("Not matched !!!");

	printf("\n");
}
        

5) What will be the output of following program ?
#include <stdio.h>
int main()
{
	int a=10;
	if(a==10)
	{
		printf("Hello...");
		break;
		printf("Ok");
	}
	else
	{
		printf("Hii");
	}
	return 0;
}
  1. Hello...
  2. Hello...OK
  3. OK
  4. Error

6) What will be the output of following program ?
#include <stdio.h>
int main()
{
	if( (-100 && 100)||(20 && -20) )
		printf("%s","Condition is true.");
	else
		printf("%s","Condition is false.");
	return 0;
}
  1. Condition is true.
  2. Condition is false.
  3. No output
  4. ERROR


7) What will be the output of following program ?
#include <stdio.h>
#define TRUE 1
int main()
{
	if(TRUE)
		printf("1");
		printf("2");
	else
		printf("3");
		printf("4");
	return 0;
}
  1. ERROR
  2. 1
  3. 12
  4. 2

8) What will be the output of following program ?
#include <stdio.h>
int main()
{
	int pn=100;
	if(pn>20)
		if(pn<20)
			printf("Heyyyyy");
	else
		printf("Hiiiii");
	return 0;
}
  1. No output
  2. Hiiiii
  3. Heyyyyy
  4. HeyyyyyHiiiii

9) Which of the following are incorrect statements? If int a=10.
1)  if( a==10 )   printf("IncludeHelp");
2)  if( 10==a )   printf("IncludeHelp");
3)  if( a=10  )   printf("IncludeHelp");
4)  if( 10=a  )   printf("IncludeHelp");
  1. 3 and 4.
  2. 3 only.
  3. 4 only.
  4. 2,3 and 4.

10) What will be the output of following program ?
#include <stdio.h>
int main()
{
	int a=10;
	if(10L == a)
		printf("10L");
	else if(10==a)
		printf("10");
	else
		printf("0");
	return 0;
}
  1. 10.
  2. 10L.
  3. 10L10.
  4. ERROR.





Comments and Discussions!

Load comments ↻





Copyright © 2024 www.includehelp.com. All rights reserved.