Control Structures — Part 1 MCQs with Explanations
Practice high-yield Programming & Software Development MCQs on Control Structures — Part 1 with worked academic solutions for FPSC, PPSC, NTS, NITB, PTS.
Questions
40
Difficulty Level
Exam-Level
Target Exams
FPSC, PPSC, NTS...
Estimated Time
48 mins
Exam-Level FPSC PPSC NTS NITB PTS
Verified for Commission Syllabus • Oct 14, 2026
40
Verified Practice Questions
Interactive test mode with detailed academic worked solutions
Live Progress|0/40 answered
✓0 correct
✗0 wrong
0% score
🎉 Set complete! All 40 questions answered.
Question 1 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
How many times will a 'do-while' loop execute its body if the condition is initially false in C?
Correct Answer: Option B — 1 time
Detailed Academic Explanation:
In C, a do-while loop executes its body at least once, even if the condition is initially false. This is because the condition is evaluated after the body of the loop has been executed. If the condition is false after the first execution of the body, the loop terminates. Therefore, even if the condition is initially false, the loop body will execute once before the condition is evaluated. So, the correct answer is Option B: 1 time .
💡Key Conceptual Anchor:Control Structures
Question 2 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
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"); } }
Correct Answer: Option A — Enter a number:99
Detailed Academic Explanation:
since this program isn't having any syntax error so program is executed. It is clearly seen that 99 is not divisible by 5. So if statement will not execute and program will terminate.
💡Key Conceptual Anchor:Control Structures
Question 3 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
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); }
Correct Answer: Option B — Enter your age: xyz You have lived for 0.00000 seconds
Detailed Academic Explanation:
When we give scanf () a "%f" format string, that means "We want you to try and get us a floating point number. When we provide input like 'xyz', it's not going to match anything, because 'xyz' is not a valid floating-point number.
💡Key Conceptual Anchor:Control Structures
Question 4 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
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); }
Correct Answer: Option C — Enter your age: xyz Your age is not valid
Detailed Academic Explanation:
When we give scanf () a "%f" format string, that means "We want you to try and get us a floating point number. When we provide input like 'xyz', it's not going to match anything, because 'xyz' is not a valid floating-point number.
💡Key Conceptual Anchor:Control Structures
Question 5 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
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); }
Correct Answer: Option C — 10 20 21 10
Detailed Academic Explanation:
The scope of second declaration of i is limited to the block in which it is defined. Outside of the block variable is not recognized.
💡Key Conceptual Anchor:Control Structures
Question 6 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
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); } }
Correct Answer: Option C — 20 20
Detailed Academic Explanation:
comma operator is executed from left to right so until j<20 for loop statement is true, so both i and j are incremented. So, i = 20 and j = 20.
💡Key Conceptual Anchor:Control Structures
Question 7 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What will be the output given program? #include<stdio.h> void main() { int i = -10; for(;i;printf("%d ", i++)); }
Correct Answer: Option A — -10 to -1
Detailed Academic Explanation:
for loop can be initialized outside of the loop. Since until -1 value of i remain a non-zero value and hence the condition is true up to -1. But when i is further increases its value becomes 0 and condition becomes false and loop stops there. Note :In C any non-zero value(positive or negative) evaluates to true and only zero value is evaluates to false .
💡Key Conceptual Anchor:Control Structures
Question 8 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
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++); }
Correct Answer: Option C — 6 6
Detailed Academic Explanation:
Here if condition evaluates to true as a non-zero value i.e 5 is assigned to a. So the value of a = 5 and after increment value of b = 6. In printf statement due to pre-increment of a value of a printed will be 6 and due to post-increment of b value of b printed will be 6 and not 7.
💡Key Conceptual Anchor:Control Structures
Question 9 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What will be the output of the given program? #include<stdio.h> void main() { int value=0; if(value) printf("well done "); printf("examveda"); }
Correct Answer: Option B — examveda
Detailed Academic Explanation:
As the value of variable value is zero so, it evaluates to false in the if condition.
💡Key Conceptual Anchor:Control Structures
Question 10 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
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); }
Correct Answer: Option D — 100 0 100
Detailed Academic Explanation:
Expression value2%5 is equal to 0 and this value assigned to value1. Therefore if condition reduces to if ( 0 ) so it fails. Therefore body of if will not be executed i.e num = 5 will not be assigned. So at printf num = 100 , value1 = 0 and value2 = 100 .
💡Key Conceptual Anchor:Control Structures
Question 11 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
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); }
Correct Answer: Option D — Complier error
Detailed Academic Explanation:
compiler error switch expression is not integral. switch statement cannot work on float value.
💡Key Conceptual Anchor:Control Structures
Question 12 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What will be the output of given program? #include<stdio.h> void main() { int a=1; if("%d=hello", a); }
Correct Answer: Option B — no error no output
Detailed Academic Explanation:
the if is conditional and it checks for expression whether it is zero or non-zero so it doesn't print any data it is clear and it is clearly seen that there is not a single syntax error therefore no complier error. After compling the program will be executed but there is not a single printf statement so it is executed but will not give any output.
💡Key Conceptual Anchor:Control Structures
Question 13 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What will be the output of given program? #include<stdio.h> void main() { int a=3; for(;a;printf("%d ", a--); }
Correct Answer: Option C — 3 2 1
Detailed Academic Explanation:
Decrement operator in for loop statement are executed until the condition is true. So it is executed till " a " not equal to zero and printf statement inside for loop print a value of " a "
💡Key Conceptual Anchor:Control Structures
Question 14 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What will be the output of given program? #include<stdio.h> void main() { int i=1, j=-1; if((printf("%d", i)) < (printf("%d", j))) printf("%d", i); else printf("%d", j); }
Correct Answer: Option A — 1 -1 1
Detailed Academic Explanation:
Here if statement is executed since we know that printf () function return the number of character print. Here printf ( " %d ", i ) return 2 because it print 1 and newline i.e 2. And, printf ( " %d ', j ) return 3 because it print -1 and newline i.e number of character is 3. Therefore if statement look like if( 2<3) yes its true. So if statement will execute. And answer is 1 -1 1.
💡Key Conceptual Anchor:Control Structures
Question 15 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What will be the output of the following piece of code? for(i = 0; i<10; i++); printf("%d", i);
Correct Answer: Option A — 10
Detailed Academic Explanation:
Due to semicolon(;) at the end of the for loop, after 10 iterations for loop will be terminated and the result will be 10.
💡Key Conceptual Anchor:Control Structures
Question 16 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What will be the output of the following code? #include<stdio.h> void main() { int s=0; while(s++<10) { if(s<4 && s<9) continue; printf("%dt", s); } }
Correct Answer: Option C — 4 5 6 7 8 9 10
Detailed Academic Explanation:
' If ' statement only true when value of ' s ' is less then 4
💡Key Conceptual Anchor:Control Structures
Question 17 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
Which command is used to skip the rest of a loop and carry on from the top of the loop again?
Correct Answer: Option C — continue
Detailed Academic Explanation:
Syntax: continue ; Causes control to pass to the end of the innermost enclosing while, do, or for statement, at that point the loop continuation condition is re-evaluated. Example: for (i = 0; i < 20; i ++ ) { if (array[i] == 0) continue ; array[i] = 1/array[i]; }
💡Key Conceptual Anchor:Control Structures
Question 18 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What is the output of the following program? #include<stdio.h> int c[10] = {1,2,3,4,5,6,7,8,9,10}; main() { int a, b=0; for(a=0;a<10;++a) if(c[a]%2 == 1) b+=c[a]; printf("%d", b); }
Correct Answer: Option C — 25
Detailed Academic Explanation:
Condition if(c[a]%2 == 1) forces only odd numbers to add in the sum.
💡Key Conceptual Anchor:Control Structures
Question 19 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What is the output of the following statements? for(i=10; i++; i<15) printf("%d ", i);
Correct Answer: Option D — Infinite loop
Detailed Academic Explanation:
Since the condition is always true it will go to infinite loop.
💡Key Conceptual Anchor:Control Structures
Question 20 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What's wrong in the following statement, provided k is a variable of type int? for ( k = 2, k <=12, k ++)
Correct Answer: Option E — The commas should be semicolons.
Detailed Academic Explanation:
In for loop the three statements parts are separated by two semicolons which are missing here.
💡Key Conceptual Anchor:Control Structures
Question 21 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
Find the output of the following program. #include<stdio.h> void main() { int y=10; if(y++>9 && y++!=10 && y++>11) printf("%d", y); else printf("%d", y); }
Correct Answer: Option C — 13
Detailed Academic Explanation:
Here if Statement is true and if statement executes left to right. Since its AND operator so all the condition should be check until it finds any false statement. Initially y = 10 In 1st condition: y++>9 which is true and y become 11 in next use. In 2nd condition: y++!=10 which is also true and y become 12 in next use In 3rd condition: y++>11 which is also true and y become 13 in next use After that printf statement will execute and print y = 13
💡Key Conceptual Anchor:Control Structures
Question 22 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What is the right choice, if the following loop is implemented? void main() { int num = 0; do{ --num; printf("%d", num); }while( ++num >= 0 ); }
Correct Answer: Option D — The loop will run infinitely many times.
Detailed Academic Explanation:
As the value of num is decremented(--num) and again incremented(++num) and hence no change in num and it remains 0 only causing infinite loop.
💡Key Conceptual Anchor:Control Structures
Question 23 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What will be the final value of the digit? void main() { int digit = 0; for( ; digit <= 9; ) digit++; digit *= 2; --digit; }
Correct Answer: Option C — 19
Detailed Academic Explanation:
First of all for loop have no braces so for loop on have only next line in its body. for( ; digit <= 9; ) digit++; After completing for loop digit = 10; next statement digit *= 2; i.e digit = digit * 2 = 20 ; next statement digit--; i.e 20-- => 19 So final value of digit is 19
💡Key Conceptual Anchor:Control Structures
Question 24 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What will be the following code's output if choice = 'R'? switch(choice) { case 'R' : printf("RED"); case 'W' : printf("WHITE"); case 'B' : printf("BLUE"); default : printf("ERROR");break; }
Correct Answer: Option B — RED WHITE BLUE ERROR
Detailed Academic Explanation:
As the first option is matching, the cases are evaluated till the break statement is encountered or end of switch statement is encountered.
💡Key Conceptual Anchor:Control Structures
Question 25 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
Consider the following program fragment: for(c=1, sum=0; c <= 10; c++) { scanf("%d", &x); if( x < 0 ) continue; sum += x; } What would be the value of sum for the input 1, -1, 2, -2, 3, -3, 4, -4, 5, -5
Correct Answer: Option E — 15
Detailed Academic Explanation:
It is summation of 1+2+3+4+5 as continue statement is going to be executed for every input of -1, -2, -3, -4, -5.
💡Key Conceptual Anchor:Control Structures
Question 26 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
Consider the following code: void main() { int a[5] = {6,8,3,9,0}, i=0; if(i != 0) { break; printf("%d", a[i]); } else printf("%d", a[i++]); } What is the output of the above program?
Correct Answer: Option D — Syntax error
Detailed Academic Explanation:
break can't be used with selection control structures, but can used with repetitive( for, while ), or select control structure( switch ).
💡Key Conceptual Anchor:Control Structures
Question 27 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What will be the output of the following C code? #include <stdio.h> void main() { int i = 0; if (i == 0) { printf("Hello"); break; } }
Correct Answer: Option D — Compile time error
Detailed Academic Explanation:
The correct answer is D: Compile time error Here's why: In C, the `break` statement is used to exit loops (like `for`, `while`, or `do-while`) or `switch` statements. It's designed to jump out of these control structures. In this code, `break` is placed directly inside an `if` block, but not within any loop or `switch`. The C compiler will detect that `break` is used in an invalid context. Therefore, the program will result in a compile-time error , indicating that the `break` statement is misplaced. The program won't even run. In summary: The `break` statement is only valid inside loops or `switch` statements.
💡Key Conceptual Anchor:Control Structures
Question 28 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What will be the output of the following C code? #include <stdio.h> int x; void main() { if (x) printf("hi"); else printf("how are u"); }
Correct Answer: Option B — how are you
Detailed Academic Explanation:
#include <stdio.h> : This line includes the standard input/output library, which is needed for the printf function. int x; : This declares an integer variable named x . Crucially, x is declared globally but *not* initialized . This means it will have a default value. void main() : This is the main function where the program execution begins. if (x) : This is the core of the question. The if statement checks the value of x . In C, any non-zero value is treated as true , and zero is treated as false . printf("hi"); : This line will be executed if the condition x is true . else printf("how are u"); : This line will be executed if the condition x is false . Now, the key point is that since x is a global variable and is not explicitly initialized , it's automatically initialized to 0 by the C compiler. Therefore, the condition if (x) is equivalent to if (0) , which is false . So, the else block will be executed, and the program will print "how are u". Therefore, the correct answer is Option B: how are you
💡Key Conceptual Anchor:Control Structures
Question 29 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What will be the output of the following C code? #include <stdio.h> int main() { switch (printf("Do")) { case 1: printf("First\n"); break; case 2: printf("Second\n"); break; default: printf("Default\n"); break; } }
Correct Answer: Option C — DoSecond
Detailed Academic Explanation:
In this code, the switch statement is evaluating the result of the printf("Do") function call. The printf() function returns the number of characters printed. When printf("Do") is executed, it prints "Do" to the standard output and returns the number of characters printed, which is 2. So, the switch statement evaluates the value 2. Since there is a case 2 in the switch statement, it will execute the corresponding code block, which prints "Second" to the standard output. Therefore, the correct output of the code will be DoSecond . So, the correct answer is Option C: DoSecond .
💡Key Conceptual Anchor:Control Structures
Question 30 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
Which control structure is used to repeatedly execute a block of code in C?
Correct Answer: Option D — while loop
Detailed Academic Explanation:
while loop is the correct answer to “Which control structure is used to repeatedly execute a block of code in C”. This question is standard in competitive examination syllabi for Control Structures.
💡Key Conceptual Anchor:Control Structures
Question 31 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
In C, what is the purpose of the 'break' statement within a loop?
Correct Answer: Option C — Terminate the loop and exit it
Detailed Academic Explanation:
Terminate the loop and exit it is the correct answer to “In C, what is the purpose of the 'break' statement within a loop”. This question is standard in competitive examination syllabi for Control Structures.
💡Key Conceptual Anchor:Control Structures
Question 32 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What is the purpose of the 'else' statement in C's 'if-else' control structure?
Correct Answer: Option B — Execute the 'else' block
Detailed Academic Explanation:
Execute the 'else' block is the correct answer to “What is the purpose of the 'else' statement in C's 'if-else' control structure”. This question is standard in competitive examination syllabi for Control Structures.
💡Key Conceptual Anchor:Control Structures
Question 33 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
Which control structure is used to make a decision between two or more alternatives in C?
Correct Answer: Option C — if statement
Detailed Academic Explanation:
if statement is the correct answer to “Which control structure is used to make a decision between two or more alternatives in C”. This question is standard in competitive examination syllabi for Control Structures.
💡Key Conceptual Anchor:Control Structures
Question 34 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What is the result of the expression 5 > 3 && 4 < 6 in C?
Correct Answer: Option A — TRUE
Detailed Academic Explanation:
TRUE is the correct answer to “What is the result of the expression 5 > 3 && 4 < 6 in C”. This question is standard in competitive examination syllabi for Control Structures.
💡Key Conceptual Anchor:Control Structures
Question 35 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
In C, what happens if the 'default' case is missing in a 'switch' statement?
Correct Answer: Option B — It has no effect
Detailed Academic Explanation:
It has no effect is the correct answer to “In C, what happens if the 'default' case is missing in a 'switch' statement”. This question is standard in competitive examination syllabi for Control Structures.
💡Key Conceptual Anchor:Control Structures
Question 36 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What is the purpose of the 'continue' statement in C?
Correct Answer: Option C — Skip the current iteration
Detailed Academic Explanation:
Skip the current iteration is the correct answer to “What is the purpose of the 'continue' statement in C”. This question is standard in competitive examination syllabi for Control Structures.
💡Key Conceptual Anchor:Control Structures
Question 37 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What is the result of the expression !(5 == 5) in C?
Correct Answer: Option B — FALSE
Detailed Academic Explanation:
FALSE is the correct answer to “What is the result of the expression !(5 == 5) in C”. This question is standard in competitive examination syllabi for Control Structures.
💡Key Conceptual Anchor:Control Structures
Question 38 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
In C, which control structure is used to iterate through a collection of items, such as an array or a list?
Correct Answer: Option A — for loop
Detailed Academic Explanation:
for loop is the correct answer to “In C, which control structure is used to iterate through a collection of items, such as an array or a list”. This question is standard in competitive examination syllabi for Control Structures.
💡Key Conceptual Anchor:Control Structures
Question 39 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What is the purpose of the 'if' control structure in C?
Correct Answer: Option B — Decision making
Detailed Academic Explanation:
Decision making is the correct answer to “What is the purpose of the 'if' control structure in C”. This question is standard in competitive examination syllabi for Control Structures.
💡Key Conceptual Anchor:Control Structures
Question 40 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
In C, what happens if the 'break' statement is used outside of a loop or switch statement?
Correct Answer: Option B — It generates a compilation error
Detailed Academic Explanation:
It generates a compilation error is the correct answer to “In C, what happens if the 'break' statement is used outside of a loop or switch statement”. This question is standard in competitive examination syllabi for Control Structures.
💡Key Conceptual Anchor:Control Structures
✓Link copied to clipboard
Continue Your Practice
Advance Html — Part 1
Master the next curriculum module with 40 exam-standard MCQs.
💡Examiner's Advisory for Programming & Software Development
In competitive commission exams (FPSC, PPSC, KPPSC, SPSC, CSS, PMS), questions are frequently phrased with distractor options designed to catch rote learners. Whenever you answer an MCQ, read the Detailed Academic Explanation and Conceptual Anchor to understand why the remaining options are incorrect.