Short Part Structured Programming Language
Short Part Structured Programming Language
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;
int arr[n];
return 0;
}
Ans of 45:
#include <stdio.h>
int main() {
int i, j, n;
printf("Enter the number of rows: ");
scanf("%d", &n);