If-Else Statements
Arrays
Loops
Functions
5

What is the purpose of an if-else statement in C?

To execute a block of code based on whether a condition evaluates to true or false.

5

What is an array in C programming?

An array is a collection of elements of the same data type, stored in contiguous memory locations.

5

What is the basic structure of a for loop in C?

for (initialization; condition; update) {    // code }

5

How do you declare a function in C that returns an integer?

int functionName();

10

What data types can be used in the condition of an if-else statement?

Conditions generally use integer or boolean values. In C, non-zero values are true, and zero is false.

10

How do you declare an integer array named num of size 5 in C?

int num[5];

10

What is the difference between a while loop and a do-while loop?

A while loop checks the condition before executing the loop body, while a do-while loop executes the loop body at least once before checking the condition.

10

What is a function in C programming?

A function is a block of code that performs a specific task, can be called multiple times, and may return a value.

15

int x = 5; if (x < 10 && x > 10) printf("Small\n"); else printf("Big\n");

Big

15

What will be the output of the following code? 

int arr[] = {10, 20, 30}; printf("%d", arr[1]);

20

15

What will be the output of this code? 

int i = 0; 

while (i < 3) {    printf("%d ", i);    i++; }

0 1 2

15

What is the syntax for declaring a function in C?

return_type function_name(parameter_list) {    

// function body 

return value

}

20

What does this code print if the user inputs 90? 

int score;

scanf("%d", &score);

if (score >= 90) printf("A"); 

else if (score >= 80) printf("B");

else printf("C");


A

20

Write a program that calculates the sum of elements in an integer array.

int arr[5] = {1, 2, 3, 4, 5};

int sum = 0;

for (int i = 0; i < 5; i++) sum += arr[i];

printf("%d", sum);


20

Write a program using a loop to print the first 10 natural numbers.

for (int i = 1; i <= 10; i++) {

    printf("%d ", i);

}


20

Write a function add(int a, int b) that returns the sum of two integers.

int add(int a, int b) { return a + b; }


25

Write a program to check if a number is even or odd using the if-else statement.

int num;

printf("Enter a number: ");

scanf("%d", &num);

if (num % 2 == 0) printf("Even\n");

else printf("Odd\n");


25

How do you find the largest number in an array of size 10?

int arr[10] = {1, 3, 5, 7, 9, 2, 4, 6, 8, 0};

int max = arr[0];

for (int i = 1; i < 10; i++) {

    if (arr[i] > max) max = arr[i];

}

printf("Largest: %d", max);


25

What is the output of the following code? 

int x = 5;

do {

    printf("%d ", x);

    x--;

} while (x > 0);


5 4 3 2 1

25

Write a C function that takes a single integer as input, squares it, and returns the result.

int square(int num) {    return num * num; }

M
e
n
u