Structured Programming
SWE · Midterm · Fall 25
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
Mid Examination - Fall 2025
Course Code: SE 121; Course Title: Structured Programming
Sections & Teachers: All; MSS, JIC, MR, AHZ, SCS, MBH, AJE
Time: 1.5 Hours
Marks: 25
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) Interpret the output and explain value changes at each step. [Marks-4] [CLO-1, Level-2]
#include <stdio.h>
int main() {
int a=15, b=7, c, d;
b = a++;
c = --b;
d = (a>b) && (b>c);
printf ("%d\n %d\n %d\n %d\n", a, b, c, d);
}
1. b) Rewrite both programs in a correct and compilable form. [Marks-6] [CLO-1, Level-2]
i) #include<stdio.h>
int main {
int num = 42;
float PI_VAL = 3.14159;
printf("Number: %f\n", num);
printf("PI: %f\n", PI_VAL);
return;
}
ii) #include <stdio.h>
int main () {
float number;
scanf("%f", number);
int res = sqroot(number);
printf("Result is: %d\n", res);
return 0;
}
2. a) A restaurant wants to automate billing. [Marks-4] [CLO-2, Level-3]
Item Code | Item Name | Price (BDT)
1 | Burger | 180
2 | Pizza | 250
3 | Pasta | 200
Build a C program using a switch-case where the user enters an item code (1-3) and quantity, then displays the total bill or "Invalid choice" for an invalid code.
Sample Input | Sample Output
Enter item code (1-3): 2
Enter quantity: 3 | Total Bill = 750 BDT
2. b) Construct a C program to simulate the Deshi Squid Game. A player starts with 1000 taka and plays 5 rounds. [Marks-6] [CLO-2, Level-3]
- Winning a round adds 500 taka.
- Losing a round deducts 500 taka.
- If the balance becomes 0 or less, the player is eliminated, and the game stops immediately.
- After the game ends, display the final balance and whether the player survived or was eliminated.
Sample Input | Sample Output
Round 1 result (1 = Win, 0 = Lose): 1
Round 2 result (1 = Win, 0 = Lose): 0
Round 3 result (1 = Win, 0 = Lose): 1
Round 4 result (1 = Win, 0 = Lose): 1
Round 5 result (1 = Win, 0 = Lose): 1 | Final Balance: 2500
Status: Survived!
Sample Input | Sample Output
Round 1 result (1 = Win, 0 = Lose): 0
Round 2 result (1 = Win, 0 = Lose): 0 | Player Eliminated!
Balance reached 0.
2. c) A smart security system verifies a user's access code by checking the sum of its digits. [Marks-5] [CLO-2, Level-3]
Construct a C program using a loop that takes a numeric code as input and calculates the sum of all its digits.
Sample Input | Sample Output
Enter the code number: 567 | Sum of Digits = 18
Sample Input | Sample Output
Enter the code number: 511 | Sum of Digits = 7