0% found this document useful (0 votes)
27 views3 pages

C - Programming Question Bank-1

The document is a C programming question bank divided into five sections covering fundamentals, branching structures, loops, arrays and strings, and problem-solving with output tracing. Each section contains various questions and programming tasks aimed at assessing knowledge and skills in C programming. Examples include evaluating expressions, writing programs for leap year checks, and tracing code outputs.
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)
27 views3 pages

C - Programming Question Bank-1

The document is a C programming question bank divided into five sections covering fundamentals, branching structures, loops, arrays and strings, and problem-solving with output tracing. Each section contains various questions and programming tasks aimed at assessing knowledge and skills in C programming. Examples include evaluating expressions, writing programs for leap year checks, and tracing code outputs.
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/ 3

C- Programming Question Bank

Section 1: Fundamentals (Variables, Data Types,


Operators, Expressions)
1. Explain the difference between ++i and i++ with a suitable
example.
2. Evaluate the following expression and show each step:
a+b*c/d-e%f
where a=10, b=20, c=15, d=5, e=12, f=4.
3. Identify the type and value of the expression:
(x > y) ? x : y
Assume x = 8, y = 5.
4. What is the output of the following code? Justify your
answer.
c

#include <stdio.h>
int main() {
int a = 5, b = 3;
printf("%d\n", a & b);
printf("%d\n", a | b);
return 0;
}

Section 2: Branching Structures (if, if-else, switch,


break, continue)
5. Write a program to check if a year is a leap year or not
using if-else.
6. Write a program to input a character and check if it is a
vowel or consonant using switch.
7. What is the purpose of break and continue? Give an example for
each.
8. Correct the following code and explain the error:
c

#include <stdio.h>
int main() {
int marks = 85;
switch(marks) {
C- Programming Question Bank

case 75: printf("Distinction"); break;


case 60: printf("First Class"); break;
default: printf("Pass");
}
return 0;
}

Section 3: Loops (while, do-while, for, nested loops)


9. Write a program to print the multiplication table of a
number n using a for loop.
10. Write a program to find the factorial of a number using
a while loop.
11. Write a program to print the following pattern using
nested loops:
*
**
***
****

12. Differentiate between for, while and do-while loops with


an example.

Section 4: Arrays and Strings


C- Programming Question Bank

13. Write a program to find the smallest number in an


array of 10 integers.
14. Write a program to read and print a string
using gets() and puts().
15. Write a program to concatenate two strings without
using strcat().
16. Write a program to find the length of a string without
using strlen().
17. Write a program to multiply two 2x2 matrices and print
the result.
18. Explain the following string functions with examples:
o strcat()
o strlen()
o strrev()

Section 5: Problem Solving & Output Tracing


19. Trace the output of the following code:
#include <stdio.h>
int main() {
int i, j;
for(i = 1; i <= 3; i++) {
for(j = 1; j <= i; j++) {
printf("%d ", j);
}
printf("\n");
}
return 0;
}
20. Write a program to calculate the sum of the series:
1 + 1/2 + 1/3 + ... + 1/n

You might also like