Structured Programming
SWE · Midterm · Summer 25
Paper 1 of 2Section AllSwitch
Section All
Paper 1 of 2
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
Midterm Examination - Summer 2025
Course Code: SE 121; Course Title: Structured Programming
Sections & Teachers: All (MAK, ZNM, MR, JIC, SCS, AHZ, KFH, AF)
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 of the program and explain the change of values in each steps.
#include <stdio.h>
int main() {
int a=10, b=5,c,d;
c = a++;
d = --b;
b = --c;
printf("%d\n", a);
printf("%d\n", b);
printf("%d\n", c);
printf("%d\n", d);
return 0;
}
[Marks-4] [CLO-1 Level-2]
b) Rewrite both programs in a correct and compilable form.
i)
#include<stdio.h>
Include <math.h>
int main {} (
DOUBLE X;
X = 8.5;
Y = pow(x);
printf("%f %f\n", X,Y);
return 0;
)
ii)
#include <stdio.h>
#define PI 3.14
int main() {
int length=10, width == 5;
float area;
area = length x width;
printf("The area of rectangle is: %c\n", area);
return 0;
}
[Marks-6] [CLO-1 Level-2]
2. a) Suppose you are a passionate developer and you have told to design a simple restaurant recommendation system that suggests dishes based on the time of day as follows:
- If the time is between 6 AM and 11 AM - Recommendation is "Pancakes and Coffee"
- If the time is between 12 PM and 3 PM - Recommendation is "Chicken Salad"
- If the time is between 4 PM and 6 PM - Recommendation is "Samosa and Chai"
- If the time is between 7 PM and 10 PM - Recommendation is "Grilled Steak"
Solve this logic by writing a program using the C programming language.
[Marks-4] [CLO-2 Level-3]
b) Suppose you are tasked to construct a C program that uses a switch-case to calculate the area of a shape based on user choice:
1 = Circle, 2 = Square, 3 = Rectangle.
The program should input the required dimensions and display the area. Handle invalid choices properly.
Sample Input | Sample Output
Enter Choice: 1 | Area of Circle: 50.265
Enter Radius: 4 |
Enter Choice: 2 | Area of Square: 16
Enter One Side: 4 |
Enter Choice: 3 | Area of Rectangle: 12
Enter Length: 4 |
Enter Width: 3 |
[Marks-6] [CLO-2 Level-3]
c) You're helping a friend build a quirky mobile app called "Number Mirror" that shows how numbers would look if they were reflected in a magical mirror. As the backend developer, your task is to write a program that takes any positive integer as input and reverses its digits using only a loop. This reversed version is what the mirror would display.
Construct a C program for the logic of the app.
Sample Input: | Sample Output:
Enter a number: 7081 | Mirror image: 1807
[Marks-5] [CLO-2 Level-3]