C Programming Module - 2 Question Bank
C Programming Module - 2 Question Bank
Question Bank
Semester: I
Course Name & Code: C Programming (Integrated) -22CSE24
Module 2
1. Explain the working of if-else ladder statement with syntax and example.
2. Explain the working of nested if statement with syntax and example.
3. Explain the working of switch statement with syntax and example.
4. Differentiate between else if ladder and switch statement.
5. Explain the working of while loop with example.
6. Explain the working of for loop with example.
7. Explain the working of do-while loop with example.
8. Differentiate between break and continue with example.
9. Differentiate between while and do-while with an example.
10. Differentiate between if statement and while loop with an example.
11. Write a C program to input a character and check whether it is uppercase or lowercase or
any other character without using library functions.
12. Write a C program to read four values a, b, c, d and evaluate the ratio of (a + b) to (c- d)
and prints the result, if c - d is not equal to zero.
13. Write a C program to input 3 numbers and find the greatest among them using nested if-
else statement.
14. Write a C program to input numeric day value (starting from Monday as 1) and display the
corresponding name of the week day. Use switch-case for the purpose.
15. Write a C program to simulate simple calculator that performs arithmetic operators using
switch statement. Display appropriate error message, if any attempt is made to divide by
zero.
1|Page
16. Write a C program to find GCD of 2 numbers using EUCLIDs Algorithm.
17. Write a C program to find the reverse of an integer number and check whether it is
palindrome or not.
18. Write a C program to input a binary number and convert it into equivalent decimal number.
19. Write a C program to find factorial of a positive number. The program should continue as
long as the user wants. Use do-while for the same.
20. Write a for statement to print each of the following sequences of integers:
a) 1, 2, 4, 8, 16, 32
b) 3 6 9------- 300
c) -4, -2, 0, 2, 4
d) -10 -14 -18 ...... -42
e) 1 1 1 1
2 2 2 2
3 3 3 3
f) *
* *
* * *
* * * *
22. Write a C program to multiply two positive numbers without using * operator. Use goto
for the purpose.
23. Evaluate and find the output for the following code.
a) for(; ;)
printf("Hello");
b) int i;
for(i=1; i<=10; i++) ;
printf("%d ",i);
c) int count = 5;
while (count -- > 0)
printf("%d ", count);
d) count = 5;
while ( -- count > 0)
printf("%d ", count);
2|Page
e) int count = 5;
do
printf("%d ", count);
while (--count > 0);
24. Assuming that x = 5, y = 0, and z = 1 initially, what will be their values after executing
the following code segments?
(a) if (x && y)
y = 20;
else
z = 20;
(b) if (x || y || z)
y = 20;
else
z = 0;
25. Assuming that x = 2, y = 1 and z = 0 initially, what will be their values after executing
the following code segments?
(a) switch (x)
{
case 2:
x = 1;
y = x + 1;
case 1:
x = 0;
break;
default:
x = 1;
y = 0;
}
3|Page
default:
x = 1;
y = 2;
}
26. Find errors, if any, in each of the following segments and correct them.
(a) if (x + y = z && y > 0)
printf(“ “);
4|Page