Skip to content

Structured Programming

SWE · Final · Spring 25

This browser can’t show the PDF here

Open it, and your phone’s PDF viewer takes it, or download it.

Read the questions as text

Read off the PDF by AI, so it may have mistakes. The PDF is the original.

Daffodil International University Department of Software Engineering Faculty of Science & Information Technology Final Examination, Spring 2025 Course Code: SE 121; Course Title: Structured Programming Sections & Teachers: MTK(A, B), SA(C), SCS(D, E), AHZ(F, G) MSA (H), MR (I, J, M), JIC (K, L), MSSS (N), ST (O), MRN (P), NML (Q) Marks: 40 Time: 2 Hours 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] | CLO-3 Level-3 i) | ii) #include <stdio.h> | #include <stdio.h> int main() | int main() { { | char q1[5], q2[5]; int arr[3] = {1, 2, 3, 4}; | gets(q1, q2); for(int i = 0; i < 4; i++) | printf("You entered: %s and %", q1, q2); printf("%d ", arr[i]); | return; return -1; | } } 1. b) Suppose you are working as a junior intern at a local weather station. Your task is to analyze the weekly temperature data to find the average temperature over 7 days. | [Marks-7] Construct a C program that uses an array to store daily temperatures (°C) over a week and compute the average temperature. Sample Input: | Sample Output: Enter temperature for Day 1: 30 | Average Temperature = Enter temperature for Day 2: 32 | 31.14 Enter temperature for Day 3: 31 | Enter temperature for Day 4: 29 | Enter temperature for Day 5: 35 | Enter temperature for Day 6: 33 | Enter temperature for Day 7: 28 | 1. c) Suppose you are building a simple registration system for a workshop. The system should take first and last names separately and then display the full name. | [Marks-7] Construct a C program that concatenates the first and last name and displays the full name. Sample Input: | Sample Output: Enter First Name: Sarah | Full Name: Sarah Khan Enter Last Name: Khan | 2. a) Identify the output of the following C codes and Explain the reasoning behind your answer. | [Marks-6] | CLO-4 Level-4 i) | ii) #include <stdio.h> | #include <stdio.h> int modify(int a) | int calculate(int x, int y) { | { if (a % 3 == 0) | if (x > y) return a + 5; | return x - y; else | else return a - 2; | return x + y; } | } int main() | int main() { | { int i, result = 0; | int p = 8, q = 5; for(i = 1; i <= 5; i++) | printf("Result = %d\n", { | calculate(p, q)); result += modify(i); | printf("Result = %d\n", } | calculate(q, p)); printf("%d\n", result); | return 0; return 0; | } } 2. b) Suppose you are developing a math helper tool for primary school students. The students are having trouble recognizing the prime numbers. | [Marks-7] Analyze and simulate a function that checks whether the entered number is prime. Sample Input: | Sample Output: Enter a number: 17 | 17 is a prime number. 2. c) Suppose you are simulating an ATM system that must validate withdrawal requests. To ensure proper denomination availability, the ATM only allows withdrawals that are divisible by 500 or 1000, and only if the amount is less than or equal to the account balance. | [Marks-7] Analyze and simulate the function int withdraw (int balance, int amount) to determine whether a withdrawal amount is valid based on ATM rules (divisibility by 500 or 1000 and sufficient balance). Update the balance accordingly and write the complete C program to implement this logic. Sample Input: | Sample Output: Enter account balance: 5000 | Transaction Approved. Enter withdrawal amount: 1000 | Remaining Balance = 4000