You are on page 1of 4

Global Academy of Technology

Approved by AICTE, New Delhi, Recognized by the Govt. of Karnataka


Autonomous Institute affiliated to VTU, Belagavi,
NAAC Accredited with ‘A’ Grade
Ideal Homes Township, Rajarajeshwari Nagar, Bengaluru-98

Department of Computer Science and Engineering


Accredited by NBA 2019-2022

2022-23 Odd Semester

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) *
* *
* * *
* * * *

21. Write for statements to find the following


a) sum = 1 +11 + 111 + 1111 + .. n terms
b) sum = 12 + 22 + 32 + 42 +------- + n2
c) sum of even numbers of first n natural numbers.

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;

(c) if (x = = 0 || x & & y)


if (!y)
z = 0;
else
y = 1;

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;
}

(b) switch (y)


{
case 0:
x = 0;
y = 0;
case 2:
x = 2;
z = 2;

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(“ “);

(b) if (p < 0) || (q < 0)


printf (“ sign is negative”);

(c) if (code > 1);


a=b+c
else
a=0
Lab programs

27. Write a C program to find roots of a Quadratic equation.


28. Write a C program to find the total no. of digits and the sum of individual digits of a positive
integer.
29. Write a C program to generate the Fibonacci sequence of first N numbers.
30. Write a C program to compute Sin(x) using Taylor series approximation given by
3 5 7
Sin(x) = x - 𝑥 + 𝑥 - 𝑥 + …….
3! 5! 7!
Compare output of the program with the built- in Library function. Print both the results
with appropriate messages.

4|Page

You might also like