Note 1

Take Note:

Take a note while surfing.





Note With Ink

Give your Note a Colorful Tag.




Easy to Access

Stay on same information and in Sync wherever you are.

Note 2

Take Note:

Organize your information,It may take Shape.





Think With Ink

Differ your Content by Color.




Easy to Access

Easy to pull up your content from anywhere anytime.

Note 3

Take Note:

Don't Let information to miss,Because it take shape





Note With Ink

Simple an Easy Way to take a note.




Easy to Access

Get the same in next visit.

C Programming :: Control Instructions

Home > C Programming > Control Instructions > General Questions

1. What is the output of the following 'C' program?

#include
void main()
{
int i=3;

switch(i)
{
default:printf("zero");
case 1: printf("one");
break;
case 2:printf("two");
break;
case 3: printf("three");
break;
}
}

Answer: three

Explanation:

The default case can be placed anywhere inside the loop. It is executed only when all other cases doesn't match.

Workspace

Tags:

No Tags on this question yet!

2. What is the output of the following 'C' program?

#include
main()
{
int i=1,j=2;
switch(i)
{
case 1: printf("GOOD");
break;
case j: printf("BAD");
break;
}
}

Answer: Compiler error: case label does not reduce to an integer constant

Explanation:

The case statement can have only constant expressions (this implies that we cannot use variable names directly so an error).

Workspace

Tags:

No Tags on this question yet!

3. What is the output of the following 'C' program?

#include
void main()
{
int i=10,j=20;
j=i,j?(i,j)?i:j:j;
printf("%d %d",i,j);
}

Answer: 10 10

Explanation:

Here is no explanation for this answer

Workspace

Tags:

No Tags on this question yet!

4. What is the output of the following 'C' program?

#include
void main()
{
float i=1.5;
switch(i)
{
case 1: printf("1");
case 2: printf("2");
default : printf("0");
}
}

Answer: Compiler error: switch quantity not an integer

Explanation:

Switch statements can be applied only to integral types.

Workspace

Tags:

No Tags on this question yet!

5. How many times "Nagarro" will get printed?

#include
int main()
{
int x;

for (x=-1; x<10;x++)
{
if (x<5)
continue;
else
break;
printf("Nagarro");
}
return 0;
}

Answer: 0 times

Explanation:

Here is no explanation for this answer

Workspace

Tags:

No Tags on this question yet!

6. The use of the break statement in switch statement is

Answer: optional

Explanation:

Here is no explanation for this answer

Workspace

Tags:

No Tags on this question yet!

7. The type of the controlling statement of a switch statement cannot be of the type

Answer: float

Explanation:

Here is no explanation for this answer

Workspace

Tags:

No Tags on this question yet!

8. What will be the O/P?

void main()
{
int i=0;
switch(i){
case 0 : printf("%d",i);break;
case 1 : printf("%d",i);break;
}
}

Answer: 0

Explanation:

Here is no explanation for this answer

Workspace

Tags:

No Tags on this question yet!

9. Given the following C program, which one of the alternatives is correct?

main()
{
char status;
int balance;
balance = 1000;
status= (balance>= 1000)? 'C': 'O'
}

Answer: status= 'C'

Explanation:

Here is no explanation for this answer

Workspace

Tags:

No Tags on this question yet!

10. What is the output of the following program?

void main()
{
int B, X, Y, Z;
X=1; Y=2; Z=3;
jf ((X > 1) || (Y > 1))
if (Z > 1)
printf ("O.K /n");
else break;
if((X > 1 && (Z > 3))
printf ("Bye /n");
printf ("Hello!");
}

Answer: O.K. bye

Explanation:

Here is no explanation for this answer

Workspace

Tags:

No Tags on this question yet!