0% found this document useful (0 votes)
162 views6 pages

Unit 2 - Operators, Expression and Control Structures

This document is a question bank for a Programming in C course, focusing on operators, expressions, and control structures. It contains multiple-choice questions (MCQs) and descriptive questions covering various topics such as operator precedence, loops, conditional statements, and pointers. The document is structured into three parts: Part A with MCQs, Part B with descriptive questions, and Part C with detailed discussions on operators and control flow.

Uploaded by

rengokuakazaabcd
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
162 views6 pages

Unit 2 - Operators, Expression and Control Structures

This document is a question bank for a Programming in C course, focusing on operators, expressions, and control structures. It contains multiple-choice questions (MCQs) and descriptive questions covering various topics such as operator precedence, loops, conditional statements, and pointers. The document is structured into three parts: Part A with MCQs, Part B with descriptive questions, and Part C with detailed discussions on operators and control flow.

Uploaded by

rengokuakazaabcd
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 6

Veltech Multitech Dr.Rangarajan Dr.

sakunthala Engineering College

Department:Computer Science and Engineering/Cyber Security

231CS111-Programming in C

Year /Sem: I /I Question Bank-Unit II

Operators,Expression and Control Structures

SNO MCQ ANSWER CHAPTER


1 Which of the following operators is used to perform a logical AND A 1
operation in C?
A) &&
B) &
C) ||
D) !
2 What will be the output of the following code snippet? B 2
int a = 5, b = 2;
printf("%d", a % b);
A) 2
B) 1
C) 0
D) 5
3 In C, what is the result of the expression 5 + 3 * 2? C 3
A) 16
B) 10
C) 11
D) 8
4 Which of the following statements correctly describes operator C 4
precedence in C?
A) All operators have the same precedence.
B) Operators are evaluated in the order they appear in the expression.
C) Some operators are evaluated before others based on their
precedence level.
D) Operator precedence does not affect the evaluation of expressions.
5 What will be the output of the following code snippet? B 5
int x = 10;
if (x > 5) {
printf("Greater than 5");
} else {
printf("Not greater than 5");
}
A) Not greater than 5
B) Greater than 5
C) No output
D) Error
6 Which statement is used to select among multiple options in C? C 6
A) if
B) for
C) switch
D) goto
7 Which of the following loops will execute at least once regardless of C 7
the condition?
A) while
B) for
C) do while
D) All of the above
8 In a for loop, what is the correct syntax for the loop control statement? A 7
A) for (initialization; condition; increment)
B) for (initialization: condition: increment)
C) for { initialization; condition; increment }
D) for (initialization; condition; increment;)
9 What will be the value of x after the following operation: x = 10; x += C 8
5;?
a) 5
b) 10
c) 15
d) 20
10 Which of the following is a valid arithmetic expression? B 8
a) 10 / 0
b) 10 + (5 * 2)
c) 5 & 3
d) a + b = 10
11 Which statement is used to create a multi-way branch in C? C 9
a) if
b) for
c) switch
d) do
12 Which loop guarantees that the loop body is executed at least once? C 9
a) for
b) while
c) do-while
d) None of the above
14 What is the output of the following code? A 10
int i = 0;
while (i < 3) {
printf("%d ", i);
i++;
}
a) 0 1 2
b) 1 2 3
c) 0 1 2 3
d) 1 2
15 What is the result of the expression 10 % 3? A 10
a) 1
b) 3
c) 0
d) 2
16 Which of the following expressions has the highest precedence? a) + C 10
b) -
c) *
d) /
17 What does the else if statement allow in C? B 11
a) Single condition checks
b) Multiple condition checks
c) Loops
d) Function definitions
18 Which statement terminates a switch case in C? A 11
a) break
b) continue
c) exit
d) return
19 What will be the output of the following code? B 11
for (int i = 0; i < 5; i++) {
if (i == 2) continue;
printf("%d ", i);
}
a) 0 1 2 3 4
b) 0 1 3 4
c) 1 2 3 4
d) 0 1 2 3
20 What does the == operator do? C 12
A) Assigns a value
B) Checks for inequality
C) Checks for equality
D) Performs an XOR operation
21 Which operator can be used to check if both conditions are true? B 12
A) ||
B) &&
C) !
D) ^
22 Which of the following is a post-increment operator? A 12
A) i++
B) i–
C) ++i
D) –i

23 What does a pointer store? B 12


Actual value of a variable
B) Address of a variable
C) Both actual value and address
D) None of the above

24 Which operator is used to declare a pointer variable? B 13


A) &
B) *
C) &&
D) %
25 What does the following declaration mean? A 13
int *ptr;
a) pointer to an int
b) double pointer
c) character pointer
d) pointer to a function
26 What is the output of the following code? A 14
int a = 10;
int *p;
p = &a;
printf("%d", *p);
A) 10
B) Address of a
C) p
D) Address of p
27 Find out the output for the following program A 14
void main()
{
int x=22;
if(x=10)
printf(“True”);
else
printf(“False”);
}
A) True
B) False
C) Error
D) None
28 Find out the output for the following program A 15
void main()
{
if((-10 && 12 ) || (19 && 21))
printf(“%s”,”True”);
else
printf(“%s”,”False”);
}
A) True
B) False
C) Error
D) None
29 Choose a syntax for C Ternary Operator from the list C 15
A) condition : expression1 ? expression2
B) condition ? expression1 < expression2
C) condition ? expression1 : expression2
D) None
30 Which of the following can replace a simple if-else construct? A 15
A) Ternary operator
B) for loop
C) while loop
D) None
PART – B
1 Explain the difference between the increment (++) and decrement (--) 2
operators in C. Provide examples.
2 Describe the use of the conditional operator (?:) in C with an example. 3
3 Evaluate an arithmetic expression as shown below: 4
x = a-b/3+c*2-1 (where a = 9, b =12, and c=3)
4 What are the rules of operator precedence in C? Give an example to 5
illustrate.
5 Describe the process of type conversion in expressions in C. Why is it 6
necessary?
6 What is the structure of an if statement in C? Provide an example to 7
illustrate its usage
7 Explain the difference between the if statement and the if-else 8
statement in C with examples.
8 What is the purpose of the else if ladder in C? Provide an example. 9
9 What is the purpose of the switch statement in C? Provide a simple 10
example.
10 Write a short note for the following for loop, while loop and do-while 11
statements.
11 Compare the for loop and while loop in C. When would you prefer one 12
over the other?
12 What is the output of the programs given below? 13
#include<stdio.h>
main ()
{
int a=20,b=10,c=15,d=5;
int e;
e=(a+)*c/d;
printf(“value of (a+b)*c/d is: %d\n”, e);
}
Explain step by step process.
13 Recommend the suitable example for infinite loop using while. 15
PART-C
1 Discuss the different types of operators in C, including arithmetic, 3
relational, logical, and bitwise operators. Provide examples of each.
Explain how to evaluate arithmetic expressions in C. What role does 4
operator precedence and associativity play in this process?
2 Explain operator precedence and associativity in C. How do they affect 5
the evaluation of expressions? Give examples.
3 Provide an example that illustrates operator precedence and 6
associativity in complex expressions. Show step-by-step evaluation.
4 Explain about the various decision making and branching satements. 7
5 Describe the different types of decision-making statements in C, 8
including if, if-else, else if ladder, and switch. Provide examples for
each.
6 . Explain the purpose and syntax of the conditional operator (?:) in 10
C.Provide an example that demonstrates how it can be used to simplify
an if-else statement.
7 Discuss the control flow of goto statement and its advantages and 11
disadvantages in C programming
8 Describe the different types of loops in C, including while, do-while, 13
and for loops. Provide examples and discuss when to use each.
9 Explain how the break and continue statements affect loop execution in 14
C.Provide examples demonstrating their usage.
10 Write a c program for the following 15
a)To whether a given year is leap or not (6m)
b)To check whether the given number is Positive or integer,(6m)

You might also like