Unit-2 Questions
Unit-2 Questions
1 Marks
a) +
b) ==
c) &&
d) ++
Answer: a) +
a) True
b) False
c) Error
Answer: a) True
a)if (y && 7)
b)if (y != 7)
c) if (y == 7)
d)if (y > 7)
Answer: c) if (y == 7)
a)--
b)++
c)+=
d)+
Answer: b)++
int a = 5, b = 3;
printf("Condition 1");
else if (a == 5 || b == 3)
printf("Condition 2");
else
printf("Condition 3");
a)Condition1
b)Condition2
c)Condition 3
d)No output
Answer: b) Condition2
Which operator is used to perform a bitwise OR operation?
6. a) |
b) ||
c) &
d) &&
Answer: a) |
a) Divides a by 2
b) Multiplies a by 2
c) Adds 1 to a
1.
int a = 10;
while(a > 5) {
a--;
1.10 9 8 7 6 5
2. 10 9 8 7 6
3. 9 8 7 6 5
4. Infinite loop
Answer: 2. 10 9 8 7 6
1.while loop
2.do-while loop
3.for loop
a) Initialization
b) Condition
c) Update
Answer: a) Initialization
12 How many times will the loop run in the following code?
printf("%d", i);
}
a) 4 times
b) 5 times
c) Infinite loop
d) It won’t run
Answer: b) 5 times
13 What is the output of the following code?
int main() {
int x = 5;
return 0;
A. 5 7
B. 6 7
C. 6 6
D. 7 7
Answer: A. 5 7
A. float
B. integer
C. char
D. string
Answer: D. string
15 What is the purpose of the #include directive in C?
A. To declare variables
B. To define functions
int x = 10;
if (x++ == 10)
printf("x is 10");
} else {
A. x is 10
B. x is not 10
Answer: A. x is 10
17 What is the purpose of the break statement in a loop?
C. To declare a variable
D. To define a function
C. To declare a variable
D. To define a function
int i = 0;
while (i < 5) {
A. 0 1 2 3 4
B. 0 1 2 3 4 5
C. 1 2 3 4 5
D. 0 1 2 3
Answer: A. 0 1 2 3 4
20 Which operator has the lowest precedence
A.sizeof
B.unary
C.assignment
D.comma
Answer: D.comma
2marks
11. What are arithmetic operators, and list any four examples.
15. What is the primary difference between while and do..while statements
in C?
16. Explain how the left shift operator (<<) works with an example
19. If int a=8,b=15,c=4 then what will the value of the given expression
2*((a%5)*(4+(b-3)/( c+2)))
10 marks
1. Write a C program that takes two integers as input and performs all
arithmetic operations (addition, subtraction, multiplication, division,
and modulus). Use proper operator precedence and explain the
output for different inputs.
(i).To find the area and circumference of a circle with radius r. (5)