Control Structures – C Programming MCQ Questions and Answers

Latest C Programming - Control Structures MCQ quiz section | Questions and answer with Solution | Jobvision.in

Control Structures – C Programming MCQ Questions and Answers
Control Structures – C Programming MCQ Questions and Answers

Dear Student, welcome to C Programming - Control Structures quiz section. Are you are preparing for competitive exams, candidate should prepared C Programming - Control Structures MCQ Questions and answer. Here you can practice all the latest C Programming - Control Structures MCQ with Explanations questions and answers for free. Along with answers you can also find detailed solutions for all C Programming - Control Structures questions. These aptitude questions will help you to crack competitive exams such as IT written exams, government exams, bank exams, entrance exams etc.

1 What is the output of given program if user enter value 99?

Answer: Option A
Solution: 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.
2 What is the output of given program if user enter xyz ?

Answer: Option B
Solution: 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.
3 What is the output of given program if user enter xyz ?

Answer: Option C
Solution: 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.
4 What will be the output of the given program?

Answer: Option C
Solution: 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.
5 What will be the value of i and j after execution of following program?

Answer: Option C
Solution:
6 What will be the output given program?

Answer: Option A
Solution: 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.
7 What will be the output of the given program?

Answer: Option C
Solution: 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.
8 What will be the output of the given program?

Answer: Option B
Solution: As the value of variable value is zero so, it evaluates to false in the if condition.
9 What will be the output of the given program?

Answer: Option D
Solution: 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.
10 What will be the output of the given program?

Answer: Option D
Solution: compiler error switch expression is not integral. switch statement cannot work on float value.
16 Which command is used to skip the rest of a loop and carry on from the top of the loop again?
Answer: Option C
Solution: 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:

17 What is the output of the following program?

Answer: Option C
Solution:
18 What is the output of the following statements?

Answer: Option D
Solution: Since the condition is always true it will go to infinite loop.
19 The type of the controlling expression of a switch statement cannot be of the type ........
Answer: Option D
Solution: No explanation is given for this question Let's Discuss on Board
20
Answer: Option D
Solution: In for loop the three statements parts are separated by two semicolons which are missing here.
21 Find the output of the following program

width=332

Answer: Option C
Solution:

/

22 What will be the value of sum after the following program is executed?

width=263

Answer: Option B
Solution: No explanation is given for this question
23 What is the right choice, if the following loop is implemented?

Answer: Option D
Solution: 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.
24 What will be the final value of the digit?

Answer: Option C
Solution:
25 What will be the following code's output if choice = 'R'?

Answer: Option B
Solution: As the first option is matching, the cases are evaluated till the break statement is encountered or end of switch statement is encountered.
26 Consider the following program fragment

width=288

What would be the value of sum for the input 1, -1, 2, -2, 3, -3, 4, -4, 5, -5

Answer: Option d
Solution: 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.
27 What will be printed if the following code is executed?
Answer: Option B
Solution: No explanation is given for this question
28 Consider the following code
width=340

What is the output of the above program?

Answer: Option D
Solution: break can't be used with selection control structures, but can used with repetitive(for, while), or select control structure(switch).
29 What will be the value of i and j after execution of following program?
/
Answer: Option C
Solution:
30 What will be the output given program?
/
Answer: Option A
Solution:

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.