1. What are conditional statements and control statements in C?
List their names and write
the syntax for each.
2. Define the break and continue statements in C. Explain each with a proper example.
3. What is an array in C? What are the different types of arrays? How can you define and
initialize each type of array?
4. Explain why a null character ('\0') is important in C strings. What is the difference
between gets(), puts(), and printf() functions when dealing with strings?
5. What does the strcat() function do? Write an example to concatenate two strings.
6. Explain how strcmp() works. How can you use it to check if two strings are equal?
7. What is the purpose of the strcpy() function? Write an example showing how to copy one
string into another.
8. Why is it important to use user-defined functions in large and complex programs? What
are the four parts of a function declaration in C? Write the correct syntax
9. Explain the concept of a recursive function in C. Provide an example to calculate the
factorial of a number using recursion.
10. Write a C program to generate a Fibonacci series using a recursive function. Explain how
the function works for n = 5.
11. What is the difference between function declaration, definition, and calling? Explain with
code examples for a simple add() function.
23. Explain the working principle of the Bubble Sort algorithm with the help of the
following array:
20, 40, 30, 10.
How many passes are required to completely sort the array? What happens at the end of
each pass?
24. Write a complete C program to swap the values of two variables using pointers as
function arguments. Describe the role of * and & in the function.
25. What is the purpose of the following C file handling functions?
a) fopen()
b) fclose()
c) feof()
d) ferror()
26. How does calloc() differ from malloc() in dynamic memory allocation?
44. Write a C program to find and print the sum of all even numbers present in an array of
integers.
45. Write a C program using nested for loops to print the following pattern for n rows:
*
**
***
****
*****
Ans of 44:
#include <stdio.h>
int main() {
int n, i, sum = 0;
printf("Enter the number of elements: ");
scanf("%d", &n);
int arr[n];
printf("Enter %d integers:\n", n);
for(i = 0; i < n; i++) {
scanf("%d", &arr[i]);
}
for(i = 0; i < n; i++) {
if(arr[i] % 2 == 0) {
sum += arr[i];
}
}
printf("Sum of even numbers: %d\n", sum);
return 0;
}
Ans of 45:
#include <stdio.h>
int main() {
int i, j, n;
printf("Enter the number of rows: ");
scanf("%d", &n);
for (i = 1; i <= n; i++) {
for (j = 1; j <= i; j++) {
printf("*");
}
printf("\n");