C Language MCQ’S | Control Instructions 15

71. What will be the output of the following C code?

#include <stdio.h>
void main()
{
int x = 0;
if (x == 0)
printf(“hi”);
else
printf(“how are u”);
printf(“hello”);
}

A) hi
B) how are you
C) hello
D) hihello


 

72.
What will be the output of the following C code?

#include <stdio.h>
void main()
{
int x = 5;
if (x < 1);
printf(“Hello”);

}

A) Nothing
B) Run time error
C) Hello
D) Varies


 

73.
What will be the output of the following C code? (Assuming that we have entered the value 1 in the standard input)

#include <stdio.h>
void main()
{
double ch;
printf(“enter a value between 1 to 2:”);
scanf(“%lf”, &ch);
switch (ch)
{
case 1:
printf(“1”);
break;
case 2:
printf(“2”);
break;
}
}

A) Compile time error
B) 1
C) 2
D) Varies


 

74.
What will be the output of the following C code? (Assuming that we have entered the value 1 in the standard input)

#include <stdio.h>
void main()
{
char *ch;
printf(“enter a value between 1 to 3:”);
scanf(“%s”, ch);
switch (ch)
{
case “1”:
printf(“1”);
break;
case “2”:
printf(“2”);
break;
}
}

A) 1
B) 2
C) Compile time error
D) No Compile time error


 

75.
What will be the output of the following C code? (Assuming that we have entered the value 1 in the standard input)

#include <stdio.h>
void main()
{
int ch;
printf(“enter a value between 1 to 2:”);
scanf(“%d”, &ch);
switch (ch)
{
case 1:
printf(“1\n”);
default:
printf(“2\n”);
}
}

A) 1
B) 2
C) 1 2
D) Run time error