Structural Programming Set2 EXAM
Structural Programming Set2 EXAM
SECTION A: 20marks
a) int[] arr;
11. In programming, structures are used to d) Person { String name; int age; }
combine multiple variables of different
types into a single entity. 15. Can a structure contain functions in
programming?
a) True
a) Yes
b) False
b) No
12. Which operator is used to access the
members of a structure in programming? c) Only if the functions have a return type
c) x and y are equal a) To terminate the loop and exit the block
SECTION B: 50marks
1. (4 marks) Explain the difference between if and if-else statements in C with code examples.
2. (3 marks) Write a C program that calculates a person's age (current year - birth year). Check if
the year entered is already the current year and adjust accordingly. Use appropriate error
handling for invalid input.
3. (3 marks) What is the logical opposite of x > 5 && y < 10? Write the code for the opposite
condition.
5. (5 marks) Write a C program that prints the multiplication table of a given user-entered number,
(from 1-12) using a for loop.
6. (3 marks) Explain the concept of an infinite loop and how to avoid it.
7. (3 marks) Write a C program that calculates the sum of all even numbers between 1 and 50.
8. (3 marks) Define an array in C and showcase its declaration and initialization with examples.
9. (6 marks) Write a C program that finds the largest element in an array of integers entered by the
user.
10. (4 marks) Write a C program that reverses the order of elements in a character array and prints
the new sequence. (Use the string “Volvo”).
Functions (5 Marks)
11. (3 marks) Explain the purpose of functions in C, including parameter passing and return values.
12. (2 marks) Write a C function that calculates the Area of a circle and returns the result.
Structures (7 Marks)
13. (3 marks) Define a structure in C and demonstrate its declaration and initialization with member
variables.
14. (4 marks) Write a C program that reads a student's name, age, and email address and stores them
in a structure. Then, print the stored information to a structure members. (note: structure name is
info and structure member, me1)