Structured Programming
SWE · Final · Spring 26
Paper 3 of 4Section All · Rubaet IslamSwitch
Section All
Paper 3 of 4
Read the questions as text
Read off the PDF by AI, so it may have mistakes. The PDF is the original.
Daffodil International University
Faculty of Science & Information Technology
Department of Software Engineering
Final-Term Examination - Spring 2026
Course Code: SE 121; Course Title: Structured Programming
Sections & Teachers: All; MTK, MSS, JIC, MR, AHZ, SCS, PS
Time: 2 Hours
Marks: 40
Answer ALL Questions
[The figures in the right margin indicate the full marks and corresponding course outcomes. All portions of each question must be answered sequentially.]
1. a) Detect any errors in the following codes and modify them with the necessary changes.
[Marks-6]
i) #include <stdio.h>
int main() {
int a[5] = {1, 'c', 3.5, 4,6};
for(int i = 0; i < 5; i++) {
printf("%d\n", arr[i]);}
a[6] = 10;
int sum;
for(int i = 0; i < 5; i++) {
sum = sum + a[i];}return 0;}
ii) #include <stdio.h>
#include <string.h>
int main() {
char s1[6] = "Hello", s2[10];
s2 = s1;
int len = strlen(s1);
printf("%s\n", s1+ 10);
printf("%d\n",len);
return 0;}
1. b) Suppose you are working as an assistant in a library's digital records section. Your task is to analyze the book borrowing data for a period of 3 days. Construct a C program that uses an array to store the number of books borrowed each day. The program should determine and display the maximum and minimum number of books borrowed during these 3 days.
[Marks-7] CLO-3 Level-3
Sample Input | Sample Output
Books borrowed on Day 1: 12 | Maximum books borrowed: 15
Books borrowed on Day 2: 8 | Minimum books borrowed: 8
Books borrowed on Day 3: 15 |
1. c) You are asked to construct a C program that takes two strings as input. The program should identify the larger string based on lexicographical (dictionary) order, and then concatenate the two strings. After concatenation, the program should calculate the length of the updated string. The output should display the larger string first, followed by the concatenated string and its length, separated by a space.
[Marks-7]
Sample Input | Sample Output
diu swe | swe diuswe 6
Amar Matha | Matha AmarMatha 9
2. a) Identify the output of the following C codes and Explain the reasoning behind your answer.
[Marks-6] CLO-4 Level-4
i) #include <stdio.h>
int fun(int arr[], int n) {
int i, result = 1;
for (i = 0; i < n; i++) {
if (arr[i] % 2 == 0)
result += arr[i];
else result = arr[i];}
return result;}
int main() {
int data[] = {3, 2, 5, 4};
printf("%d\n", fun(data, 4));
return 0;}
ii) #include <stdio.h>
int count(char str[]){
int i = 0, count = 0;
while (str[i] != '\0') {
if (str[i] == 'a' || str[i] == 'e'
|| str[i] == 'i' || str[i] == 'o' ||
str[i] == 'u')
count++; i++;}
return count;}
int main(){
char text[] = "Execution";
printf("%d\n",count(text));
return 0;}
2. b) As a junior software developer at the Bangladesh Election Commission, you are tasked with developing a system to process voter eligibility for a batch of citizens during national elections. Each day, data of multiple individuals is collected, including:
- An array storing the ages of citizens.
- An array storing their citizenship status (1 = Citizen, 0 = Not a citizen).
A person is eligible to vote if: Age >= 18 & Citizenship status = 1
Analyze the scenario and write a C program with the following function to count how many individuals are eligible to vote:
int countEligibleVoters (int ages [], int citizenship[], int number);
[Marks-7] CLO-4 Level-3
Sample Input | Sample Output
Enter number of people: 3 | Total Eligible Voters = 1
Enter age and citizenship (1/0): 20 1 |
Enter age and citizenship (1/0): 17 1 |
Enter age and citizenship (1/0): 25 0 |
2. c) Suppose you are assisting a bank employee in comprehending how a basic banking system handles customer accounts. The bank wishes to display the most recent account information, permit simple activities like deposits and withdrawals, and maintain each customer's personal information, including name, account number, and current account. Construct a C program using a structure named Account to store client data, handle deposits and withdrawals (making sure that withdrawals are only permitted when there is a sufficient balance), and show the final account balance along with additional information
[Marks-7] CLO4 Level-3
Sample Input | Sample Output
Enter name: Rehan Khan | --- Account Details ---
Enter account number: 1001 | Name : Rehan Khan
Enter initial balance: 5000 | Acc No : 1001
Enter amount to deposit: 2000 | Balance : 5500
Enter amount to withdraw: 1500 |