MCQ
Question:->1.
What will be the output of following program ?
#include <stdio.h>
void main()
int x=22;
if(x=10)
printf("TRUE");
else
printf("FALSE");
}
*
5 points
FALSE
TRUE
Error
None
Question:->2.
What will be the output of following program ?
#include <stdio.h>
void main()
char val = 1;
if(val--==0)
printf("TRUE");
else
printf("FALSE");
}
*
5 points
FALSE
TRUE
Error
None
Question:->3.
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;
}
*
5 points
Hello...
Hello...OK
OK
Error
Question:->4.
What will be the output of following program ?
#include <stdio.h>
int main()
if(TRUE)
printf("1");
printf("2");
else
printf("3");
printf("4");
return 0;
}
*
5 points
1
12
2
Error
Question:->5.
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;
}
*
5 points
HeyyyyyHiiiii
Heyyyyy
Hiiiii
No output
Question:->6.
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");
*
5 points
3 and 4.
3 Only
4 Only
2,3 and 4.
Question:->7.
What is the output of the C Program.?
int main()
if( 4 > 5 )
printf("Hurray..\n");
printf("Yes");
return 0;
}
*
5 points
Yes
Hurray..
Hurray..Yes
Compiler error
Question:->8.
What is the output of the C Program.?
#include <stdio.h>
int main()
if( (-100 && 100) || (20 && -20) )
printf("%s" , "Condition is true.");
else
printf("%s","Condition is false.");
return 0;
}
*
5 points
Condition is true.
Condition is false
No output
Error
Question:->9.
Which operator is used to compare two values in an if statement?
*
5 points
+
=
==
>
Question:->10.
What is the output of the C Program.?
int main()
if(-5)
printf("Germany\n");
if(5)
printf("Texas\n");
}
printf("ZING");
return 0;
}
*
5 points
ZING
Texas ZING
Germany Texas ZING
Compiler error
Question:->11.
What is the output of the C Program.?
int main()
if(10.0)
printf("Texas\n");
printf("ZING");
return 0;
*
5 points
ZING
Texas ZING
Germany Texas ZING
Compiler error
Question:->12.
What is the output of the C Program.?
int main()
if("abc")
printf("India\n");
if('c')
printf("Honey\n");
printf("ZING");
return 0;
}
*
5 points
ZING
Honey ZING
India ZING
India Honey ZING
Question:->13.
What is the output of the C Program.?
int main()
if(TRUE)
printf("India\n");
if(true)
printf("Honey\n");
printf("ZING");
return 0;
}
*
5 points
Honey ZING
India ZING
India Honey ZING
Compile Error
Question:->14.
What will be the output of given code.
#include <stdio.h>
int x ;
void main()
{
if (x)
printf("hi");
else
printf("how are u");
*
5 points
hi
how are you
Compile time Error
Error
Question:->15.
What will be the output of given code.
#include <stdio.h>
void main()
int x = 5;
if (true);
printf("hello");
}
*
5 points
It will display hello
It will throw an error
Nothing will be displayed
Compiler dependent
Question:->16.
What will be the output of given code. #include <stdio.h>
void main()
int x = 0;
if (x == 0)
printf("hi");
else
printf("how are u");
printf("hello");
}
*
5 points
hi
how are you
hello
hihello
Question:->17.
What will be the output of given code. #include <stdio.h>
void main()
int x = 5;
if (x > 1)
printf("Hello");
}
*
5 points
nothing
Hello
Run time error
no output
Question:->18.
What will be the output of given code.
#include <stdio.h>
void main()
int x=1 ;
if (x < 1)
printf("FBS");
else
printf("Hello");
}
*
5 points
nothing
Hello
Run time error
no output
Question:->19.
What will be the output of the following code in C?**
#include <stdio.h>
int main() {
int age = 16;
if (age >= 18) {
printf("Adult");
} else {
printf("Minor");
return 0;
}
*
5 points
Adult
16
Minor
Error
Question:->20.
What will be the output of the following code in C?**
#include <stdio.h>
int main() {
int num = -2;
if (num >= 0) {
printf("Non-negative");
} else {
printf("Negative");
return 0;
}
*
5 points
Negative
Non-Negative
-2
Error
Question:->21.
What will be the output of the following code in C?**
#include <stdio.h>
int main() {
int num1 = 10;
int num2 = 20;
if (num1 > num2) {
printf("num1 is greater");
} else {
printf("num2 is greater");
return 0;
}
*
5 points
num 1 is greater
num 2 is greater
10
20
Question 22.
#include <stdio.h>
int main()
{
int m=40,n=20;
if (m>n) {
printf("m is greater than n");
}
else if(m<n) {
printf("m is less than n"); }
else {
printf("m is equal to n");}
}
5 points
compilation error
m is greater than n
m is equal to n
m is less than n
Question 23.
#include <stdio.h>
void main()
{
int x = 5;
if (true);
printf("hello");
}
5 points
It will display hello
Nothing will be displayed
compilation error
compiler dependent
Question 24.
What will be the output of the following C code?
#include <stdio.h>
void main()
{
int x = 5;
if (x < 1);
printf("Hello");
}
5 points
Nothing will print
Run time error
Hello
Compiler dependent
Question 25.
#include <stdio.h>
int main()
{
int x = 0;
if (x++)
printf("true\n");
else if (x == 1)
printf("false\n");
}
5 points
true
false
compile time error
compiler dependent
Question 26.
What will be the output of the following C code?
#include <stdio.h>
int main()
{
int x = 0;
if (x == 0)
printf("true, ");
else if (x = 10)
printf("false, ");
printf("%d\n", x);
}
5 points
false, 0
true, 0
true, 10
compile time error
Question 27.
What will be the output of the following C code?
#include <stdio.h>
int main()
{
int a = 1;
if (a - -)
printf("True");
if (a++)
printf("False");
}
5 points
True
False
True False
nothing
Question 28.
What will be the output of the following C code?
#include <stdio.h>
int main()
{
int a = 1;
if ( a )
printf("All is Well ");
printf("I am Well\n");
else
printf("I am not a River\n");
}
5 points
Output will be All is Well I am Well
Output will be I am Well I am not a River
Output will be I am Well
Compile time errors during compilation
Question 29.
What will be the output of the following C code?
#include <stdio.h>
int main()
{
if (printf("%d", printf( " ")))
printf("We are Happy");
else if (printf("1"))
printf("We are Sad");
}
5 points
0We are Happy
1We are Happy
1We are Sad
compile time error
Question 30.
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");
}
5 points
hi
Compilation error
hello
hihello
QUIZ-
Question:->1.
1. What is a nested if-else statement in programming?
*
5 points
a) A conditional statement that can only contain one if and one else block.
b) A statement used to create loops.
c) A conditional statement placed inside another conditional statement.
d) A statement used to declare variables.
Question:->2.
2. What is the primary purpose of using nested if-else statements?
*
5 points
a) To declare variables.
b) To print output to the console.
c) To make code more concise.
d) To handle multiple conditions and make decisions based on them.
Question:->3.
In a nested if-else structure, which if-else block is executed first?
*
5 points
a) The innermost if-else block.
b) The outermost if-else block.
c) It depends on the specific conditions.
d) Both if-else blocks are executed simultaneously.
Question:->4.
What happens if the condition in the outer if statement is false in a nested if-else
structure?
*
5 points
a) The program terminates.
b) The inner if-else structure is skipped, and the program continues to the else block.
c) The program throws an error.
d) The inner if-else structure is executed.
Question:->5.
In a nested if-else structure, how many else blocks can follow a single if block?
*
5 points
a) One
b) Two
c) None
d) As many as needed
Question:->6.
What is the purpose of using else-if statements in a nested if-else structure?
*
5 points
a) To indicate the end of the if-else structure.
b) To create a loop.
c) To provide alternative conditions to check if the previous conditions are false.
d) To execute code only if the previous conditions are true.
Question:->7.
Which of the following statements is true about the execution flow in nested if-else
statements?
*
5 points
a) The program always executes the innermost if block.
b) The program always executes the else block if none of the conditions are true.
c) The program follows the execution flow based on the first condition that evaluates to true.
d) The program executes all if-else blocks simultaneously.
Question:->8.
What is the primary advantage of using nested if-else statements over multiple
independent if-else statements?
*
5 points
a) Reduced code complexity.
b) Improved code performance.
c) Enhanced code readability.
d) Greater flexibility in decision making.
Question:->9.
What happens if there is no else block following an if block in a nested structure, and
none of the conditions are true?
*
5 points
a) The program throws an error.
b) The program proceeds to execute the code after the nested structure.
c) The program enters an infinite loop.
d) The program terminates.
Question:->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;
}
*
5 points
a) 10.
b) 10L.
c) 10L10.
d) ERROR.
Question:->11.
What will be the output of the following code?
int x = 8, y = 6;
if (x > y) {
if (y != 6) {
printf("A");
} else {
printf("B");
} else {
printf("C");
}
*
5 points
a) A
b) B
c) C
d) A and B
e) None of the above
Question:->12.
What is the output of the C Program.?
int a = 5, b = 10;
if (a < b) {
if (b > 7) {
printf("X");
} else {
printf("Y");
} else {
printf("Z");
}
*
5 points
a) X
b) Y
c) Z
d) X and Y
e) None of the above
Question:->13.
What is the output of the C Program.?
int num = 15;
if (num % 3 == 0) {
if (num > 5) {
printf("A");
} else {
printf("B");
} else {
printf("C");
}
*
5 points
a) A
b) B
c) C
d) A and B
e) None of the above
Question:->14.
What will be the output of the following code?
int i = 20;
if (i > 10) {
if (i < 30) {
printf("P");
} else {
printf("Q");
} else {
printf("R");
}
*
5 points
a) P
b) Q
c) R
d) P and Q
e) None of the above
Question:->15.
What will be the output of the following code?
int x = 5, y = 5;
if (x == y) {
if (y == 5) {
printf("A");
} else {
printf("B");
} else {
printf("C");
}
*
5 points
a) A
b) B
c) C
d) A and B
e) None of the above
Question:->16.
What is the output of the C Program.?
int a = 10, b = 20;
if (a < b) {
if (b > 15) {
printf("X");
} else {
printf("Y");
} else {
printf("Z");
}
*
5 points
a) X
b) Y
c) Z
d) X and Y
e) None of the above
Question:->17.
What is the output of the C Program.?
int num = 37;
if (num % 2 == 0) {
if (num > 30) {
printf("A");
} else {
printf("B");
} else {
printf("C");
}
*
5 points
a) A
b) B
c) C
d) A and B
e) None of the above
Question:->18.
What is the output of the C Program.?
int x = 8, y = 10;
if (x > y) {
if (y != 5) {
printf("A");
} else {
printf("B");
} else {
printf("C");
}
*
5 points
a) A
b) B
c) C
d) A and B
e) None of the above
Question:->19.
What is the output of the C Program.?
int a = 15, b = 25;
if (a < b) {
if (b < 20) {
printf("X");
} else {
printf("Y");
} else {
printf("Z");
}
*
5 points
a) X
b) Y
c) Z
d) X and Y
e) None of the above
Question:->20.
What will be the output of given code.
int num = 42;
if (num > 40) {
if (num % 7 == 0) {
printf("A");
} else {
printf("B");
} else {
printf("C");
}
*
5 points
a) A
b) B
c) C
d) A and B
e) None of the above
Question:->21.
What will be the output of given code.
int x = 8, y = 6;
if (x < y) {
if (y == 6) {
printf("A");
} else {
printf("B");
}
} else {
printf("C");
}
*
5 points
a) A
b) B
c) C
d) A and B
e) None of the above
Question:->22.
What will be the output of given code.
int a = 5, b = 5;
if (a == b) {
if (b == 5) {
printf("X");
} else {
printf("Y");
} else {
printf("Z");
}
*
5 points
a) X
b) Y
c) Z
d) X and Y
e) None of the above
Question:->23.
What will be the output of given code.
int num = 11;
if (num % 2 == 0) {
if (num > 10) {
printf("A");
} else {
printf("B");
} else {
printf("C");
}
*
5 points
a) A
b) B
c) C
d) A and B
e) None of the above
Question:->24.
What will be the output of given code.
int x = 8, y = 6;
if (x > y) {
if (y != 8) {
printf("A");
} else {
printf("B");
} else {
printf("C");
}
*
5 points
a) A
b) B
c) C
d) A and B
e) None of the above
Question:->25.
What will be the output of given code.
#include <stdio.h>
void main()
int a = 5, b = 7;
if (a == 5) {
if (b != 7) {
printf("X");
} else {
printf("Y");
} else {
printf("Z");
}
*
5 points
a) X
b) Y
c) Z
d) X and Y
e) None of the above
Question:->26.
What will be the output of the following code in C?**
int num = 30;
if (num % 2 == 0) {
if (num > 25) {
printf("A");
} else {
printf("B");
} else {
printf("C");
}
*
5 points
a) A
b) B
c) C
d) A and B
e) None of the above
Question:->27.
What will be the output of the following code in C?**
int x = 5, y = 5;
if (x == y) {
if (y == 6) {
printf("A");
} else {
printf("B");
} else {
printf("C");
}
*
5 points
a) A
b) B
c) C
d) A and B
e) None of the above
Question:->28.
What will be the output of the following code in C?**
int a = 10, b = 20;
if (a > b) {
if (b > 30) {
printf("X");
} else {
printf("Y");
}
} else {
printf("Z");
}
*
5 points
a) Z
b) Y
c) X
d) X and Y
e) None of the above
Question:->29.
What will be the output of the following code in C?**
int num = 15;
if (num % 4 == 0) {
if (num > 10) {
printf("A");
} else {
printf("B");
} else {
printf("C");
}
*
5 points
a) A
b) B
c) C
d) A and B
e) None of the above
Question:->30
What will be the output of the following code?
int x = 8, y = 6;
if (x < y) {
if (y != 8) {
printf("A");
} else {
printf("B");
} else {
printf("C");
}
*
5 points
a) A
b) B
c) C
d) A and B
e) None of the above
LOOP
MCQ Test 3 : loop
[email protected] Switch account
Draft saved
* Indicates required question
Email*
Unique FirstBit ID / FirstBit Registration Number (FRN)*
Full Name*
First Name - Middle Name - Last Name
1. What will be the output of the following C code?
#include <stdio.h>
int main()
{
while ()
printf("In while loop ");
printf("After loop\n");
}
*
5 points
In while loop after loop
After loop
Compile time error
Infinite loop
2. What will be the output of the following C code?
#include <stdio.h>
int main()
{
do
printf("In while loop ");
while (0);
printf("After loop\n");
}
*
5 points
In while loop
In while loop After loop
After loop
Infinite loop
3. What will be the output of the following C code?
#include <stdio.h>
int main()
{
int i = 0;
do {
i++;
printf("In while loop\n");
} while (i < 3);
}
*
5 points
In while loop In while loop In while loop
In while loop In while loop
Depends on the compiler
Compile time error
4. How many times i value is checked in the following C code?
#include <stdio.h>
int main()
{
int i = 0;
do {
i++;
printf("in while loop\n");
} while (i < 3);
}
*
5 points
2
3
4
1
5. How many times i value is checked in the following C code?
#include <stdio.h>
int main()
{
int i = 0;
while (i < 3)
i++;
printf("In while loop\n");
}
*
5 points
2
3
4
1
6. What will be the output of the following C code?
#include <stdio.h>
void main()
{
int i = 2;
do
{
printf("Hi");
} while (i < 2)
}
*
5 points
Compile time error
Hi Hi
Hi
Varies
7. What will be the output of the following C code?
#include <stdio.h>
void main()
{
int i = 0;
while (++i)
{
printf("H");
}
}
*
5 points
H
H is printed infinite times
Compile time error
Varies
8. What will be the output of the following C code?
#include <stdio.h>
void main()
{
int i = 0;
do
{
printf("Hello");
} while (i != 0);
}
*
5 points
Nothing
H is printed infinite times
Hello
Run time error
9) What is the output of the given below program?
#include<stdio.h>
int main()
{
int i=1;
while(1)
{
printf("N");
i++;
if(i==5) break;
}
return 0;
}
*
5 points
N
NNNN
NNNNN
Compile-time error
10) What is the output of the given below program?
#include<stdio.h>
int main()
{
while(true)
{
printf("Know Program");
break;
}
return 0;
}
*
5 points
Know Program
Compiled Successfully, No Output
Know Program is printed an infinite number of times.
Compile-time error
11) Find the output of the given program?
#include<stdio.h>
int main()
{
int a = 3;
while(a == 3)
{
printf("Know Program");
break;
}
return 0;
}
*
5 points
Know Program
Compiled Successfully, No Output
Know Program is printed infinite times.
Compile-time error
12)Find the output of the given program?
#include<stdio.h>
int main()
{
int a = 5;
while(a <= 9)
{
printf("%d", a);
a++;
}
return 0;
}
*
5 points
5
5678
56789
Compile-time error
13)Find the output of the given program?
#include<stdio.h>
int main()
{
int a = 0;
while(++a)
{
printf("Know Program ");
}
return 0;
}
*
5 points
Know Program
Compiled Successfully, No Output
Know Program is printed infinite times.
Compile-time error
14)What will be the output of the following C code?
#include <stdio.h>
int main()
{
int i = 0, j = 0;
while (i < 5, j < 10)
{
i++;
j++;
}
printf("%d, %d\n", i, j);
}
*
5 points
5, 5
5, 10
10, 10
Syntax error
15)Which loop is most suitable to first perform the operation and then test the
condition?
*
5 points
for loop
while loop
do-while loop
none of the mentioned
16)Which for loop has range of similar indexes of ‘i’ used in for (i = 0;i < n; i++)?
*
5 points
for (i = n; i>0; i–)
for (i = n; i >= 0; i–)
for (i = n-1; i>0; i–)
for (i = n-1; i>-1; i–)
17)What will be the output of the following C code?
#include <stdio.h>
void main()
{
int k = 0;
for (k < 3; k++)
printf("Hello");
}
*
5 points
Compile time error
Hello is printed thrice
Nothing
Varies
18) Find the output of the given program?
#include<stdio.h>
int main()
{
int i;
for (;;)
{
printf("Know Program");
break;
}
return 0;
}
*
5 points
Know Program
Know Program is printed infinite times.
Compiled Successfully, No Output
Compile-time error
19) Find the output of the given program?
#include<stdio.h>
int main()
{
int i;
for (printf("Hello "); printf("Know "); printf("Program "))
{
break;
}
return 0;
}
*
5 points
Hello
Hello Know
Hello Know Program
Compiled Successfully, No Output
Compile-time error
20) What will be the output of the following C code?
#include <stdio.h>
void main()
{
int k;
for (k = -3; k < -5; k++)
printf("Hello");
}
*
5 points
Hello
Infinite hello
Run time error
Nothing
21) Loops in C Language are implemented using?
*
5 points
While Block
For Block
Do While Block
All the above
22) Find the output of the given program?
#include<stdio.h>
int main()
{
int a = 0;
do
{
printf("Know Program");
} while(a);
return 0;
}
*
5 points
Know Program
Know Program is printed infinite times.
Compiled Successfully, No Output
Compile-time error
23)Find the output of the given program?
#include<stdio.h>
int main()
{
int a = 1;
do
{
printf("N");
a++;
} while(a <= 5);
return 0;
}
*
5 points
N
NNNN
NNNNN
Compile-time error
24)Find the output of the given program?
#include<stdio.h>
int main()
{
int a = 1;
do
{
printf("N");
a++;
if(a==3) break;
} while(a);
return 0;
}
*
5 points
N
NN
NNN
N is printed infinite times.
Compile-time error
25)Find the output of the given below program?
#include<stdio.h>
int main()
{
int a = 9;
do
{
printf("%d ", a);
a++;
} while(a <= 5);
return 0;
}
*
5 points
9
98765
Compiled Successfully, No Output
Compile-time error
26)What is the output of C Program.?
int main()
{
int a=32;
do
{
printf("%d ", a);
a++;
}while(a <= 30);
return 0;
}
*
5 points
32
33
30
No Output
27)What is the output of C Program.?
int main()
{
int a=32;
do
{
printf("%d ", a);
a++;
if(a > 35)
break;
}while(1);
return 0;
}
*
5 points
No Output
32 33 34
32 33 34 35
Compiler error
28)What is the output of C Program.?
int main()
{
int k, j;
for(k=1, j=10; k <= 5; k++)
{
printf("%d ", (k+j));
}
return 0;
}
*
5 points
compiler error
10 10 10 10 10
11 12 13 14 15
None of the above
29)What is the output of C Program.?
void main()
{
int a=14;
while(a<20)
{
++a;
if(a>=16 && a<=18)
{
continue;
}
printf("%d ", a);
}
}
*
5 points
15 16 17 18 19
15 18 19
15 16 20
15 19 20
30)What is the output of C Program.?
int main()
{
int a=0, b=0;
while(++a < 4)
printf("%d ", a);
while(b++ < 4)
printf("%d ", b);
return 0;
}
*
5 points
01231234
1231234
12341234
12340123