0% found this document useful (0 votes)
2 views2 pages

Short Part Structured Programming Language

The document covers various concepts in C programming, including conditional and control statements, arrays, string manipulation functions, user-defined functions, recursion, sorting algorithms, and file handling. It provides code examples for practical understanding, such as calculating the sum of even numbers in an array and generating a pattern using nested loops. Additionally, it explains memory allocation functions and their differences.

Uploaded by

Niaz Ahamed
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views2 pages

Short Part Structured Programming Language

The document covers various concepts in C programming, including conditional and control statements, arrays, string manipulation functions, user-defined functions, recursion, sorting algorithms, and file handling. It provides code examples for practical understanding, such as calculating the sum of even numbers in an array and generating a pattern using nested loops. Additionally, it explains memory allocation functions and their differences.

Uploaded by

Niaz Ahamed
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

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");

You might also like