Structured Programming
SWE · Final · Fall 25
Section All
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 – Fall 2025
Course Code: SE 121; Course Title: Structured Programming
Sections & Teachers: All; MSS, JIC, MR, AHZ, SCS, MBH, AJE
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.
i) #include <stdio.h>
#include <string.h>
int main() {
char s[10] = "programming";
char d[5];
strcpy(d, s);
printf("Source: %s\n", s);
printf("Dest: %d\n", d);
return 0;
}
ii) #include <stdio.h>
int main() {
char n[5];
int i;
printf("Enter name: ");
scanf("%s", n);
for (i = 0; i <= 5; i++) {
if (n[i] == 'p') {
printf("Found p at %d\n", n); }}}
[Marks-6] | CLO-3 Level-3
b) Suppose you are working as an assistant in a library's digital records section. Your task is to analyze the weekly book-borrowing data to determine how many days a specific number of books were borrowed. Construct a C program that uses an array to store the number of books borrowed over a week (7 days) and count the frequency of a user-specified value.
Sample Input | Sample Output
Books borrowed on Day 1: 12 | The value 15 occurred 3 times this week.
Books borrowed on Day 2: 15 |
Books borrowed on Day 3: 9 |
Books borrowed on Day 4: 15 |
Books borrowed on Day 5: 18 |
Books borrowed on Day 6: 15 |
Books borrowed on Day 7: 10 |
The number of books you want to count: 15
[Marks-7] | CLO-3 Level-3
c) Suppose you are working as a tester in a software security department. Your task is to analyze user login data to verify whether an entered password matches the stored system password. Construct a C program that will take two strings to store the original password and the user-input password, then compare them to determine if access should be granted.
Sample Input | Sample Output
Original password: admin123 | Access Granted.
User password: admin123 |
Original password: swe45 | Access Denied.
User password: swe44 |
[Marks-7] | CLO-4 Level-4
2. a) Identify the output of the following C codes and Explain the reasoning behind your answer.
i) #include <stdio.h>
int test(int a[], int n) {
int i, s = 0;
for (i = 0; i < n; i += 2) {
s += a[i];}
return s;
}
int main() {
int arr[] = {2, 4, 6, 8, 10};
printf("%d\n", test(arr, 5));
return 0;
}
ii) #include <stdio.h>
int cnt(char s[]) {
int i, c = 0;
for (i = 0; s[i] != '\0'; i++) {
if (s[i] != ' ') {
c++;}
return c;
}
int main() {
char str[] = "C Prog";
printf("%d\n", cnt(str));
return 0; }
[Marks-6] | CLO-4 Level-4
b) Suppose you are helping your younger brother understand time conversion. You need to convert a given duration in total minutes into hours and remaining minutes so that he can learn how time is broken down. Construct a C program that uses a function void timeConversion(int minute) to perform this conversion and display the result in hours and minutes.
Sample Input | Sample Output
Enter Minutes: 125 | 2 hours 5 minutes
[Marks-7] | CLO-4 Level-3
c) Suppose you are working as an intern at a data analytics center. Your task is to analyze a performance matrix stored in a 2D array, where each row represents a department and each column represents recorded output values. Complete the following C program by filling in the missing portions of the function to find and return the maximum value in the entire 2D matrix.
#include <stdio.h>
int Max(int a[][10], int r, int c) {}
int main() {
int a[10][10], rows, cols, i, j;
scanf("%d %d", &rows, &cols);
for (i = 0; i < rows; i++) {
for (j = 0; j < cols; j++) {
scanf("%d", &a[i][j]); }}
printf("Max value in the matrix = %d\n", Max(a, rows, cols));
return 0;}
[Marks-7] | CLO4 Level-3