Programming and Problem Solving
CSE · Midterm · Fall 25
Paper 1 of 2Batch 69 · Md. Mahfuzur RahmanSwitch
Batch 69
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 Computer Science & Engineering
Midterm Examination, Fall 2025
Course Code: CSE113, Course Title: Programming and Problem Solving
Level: 1 Term: 2 Batch: 69
Time: 01:30 Hrs
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. From the following code identify and list all the keywords and identifiers present in the code.
#include <stdio.h>
int main() {
int total = 10;
float price = 25.5;
char greeting = '#';
if (total > 0) {
total = total + 5;
printf("%c Your total is: %d\n", greeting, total);
} else {
printf("No items found.\n");
}
return 0;
}
[02] [CO1]
2. a) Identify the syntax errors in the following code snippet. Write down each error with the line number and why you think this is an error:
1. #include <studio.h>
2. int main() {
3. int numbers[4] = {10, 20, 30, 40, 50};
4. int i;
5. for (i = 0, i <= 4, i++) {
6. if numbers[i] > 25 {
7. printf("Number %d is greater than 25\n", numbers[i]);
8. } else {
9. printf(Number %d is less than or equal to 25\n, numbers[i]);
10. }
11. }
12. return 0
13. }
[02] [CO2]
b) Write a corrected version of the above program.
[02]
3. Draw a flowchart to solve each of the following problems.
a) At the DIU canteen, students get a discount based on their total bill amount:
- If the total bill is less than 100 BDT, no discount is applied.
- If the bill is between 100 and 300 BDT (inclusive), a 10% discount is given.
- If the bill is more than 300 BDT, a 20% discount is applied.
Draw a flowchart that takes the total bill amount as input and calculates the final amount after applying the discount.
[02] [CO3]
b) Two DIU students are working on a problem to determine whether a positive integer N is a prime number. They first check if the input number is positive; if not, they ask the user to enter a positive number again and keep reading until a positive number is entered. Then, they check all numbers from 2 up to N-1 to see if any of them divides N without a remainder. If they find any such divisor, they conclude that N is not prime; otherwise, it is prime.
Draw a flowchart that inputs a number N, validates that it is positive, and then checks whether it is prime or not.
[02]
4. Identify the problem scenarios given below and write a complete C program for each problem statement.
a) You are working on an automated health data tracker for DIU Health Center. The system records a student's morning and evening pulse rate. Write a C program that takes these two integer values as input and displays their total pulse count for the day.
Input:
- First line contains two integers separated by space representing the morning and evening pulse rate.
Output:
- Print the total pulse count in a single line.
Sample Input | Sample Output
65 75 | Total pulse count in a day: 140
[02] [CO4]
b) The DIU Health Analytics Lab tracks students' strength improvement during fitness programs. Each student starts with an initial strength score S, which increases by R% every month. Write a C program to calculate the final strength score after N months.
Hints: Strength = S (1 + R/100)^N
Input:
- First line contains three numbers:
o Initial strength score S (integer)
o Monthly growth rate R (floating-point number)
o Number of months N (integer)
Output:
- Print the final strength score after N months rounded to two decimal places.
Sample Input | Sample Output
100 10 3 | Final strength score after 3 months: 133.10
[03]
c) DIU Medical Center is developing a health monitoring system to analyze students' physical condition based on their BMI and average heart rate. Write a C program that classifies their health condition according to the following rules:
Condition | Output
BMI < 18.5 and heart rate > 100 | Underweight with Tachycardia
BMI between 18.5-24.9 and heart rate between 60-100 | Healthy Condition
BMI between 25-29.9 or heart rate > 110 | Overweight or High Heart Rate
Otherwise | Consult Doctor Immediately
Input:
- Two numbers representing BMI (floating-point) and heart rate (integer).
Output:
- Print the corresponding health condition message.
Sample Input | Sample Output
26.3 115 | Overweight or High Heart Rate
[03]
d) The DIU Health Club monitors students' daily water intake to encourage proper hydration. Write a C program that takes the number of days and the amount of water (in liters) consumed each day, then prints the total and average water intake.
Input:
- First line contains an integer N representing the number of days.
- Second line contains N space-separated integers representing the daily water intake in liters.
Output:
- Print the total water intake and average intake per day (up to two decimal places).
Sample Input | Sample Output
7 | Total water intake: 14 liters
2 1 2 3 2 1 3 | Average per day: 2.00 liters
[03]
e) Two DIU students are analyzing the daily health improvement scores of a student over N days. The scores can be positive (improvement) or negative (decline). They want to find the second maximum score recorded during these days to identify the runner-up best health day.
Input:
- First line contains an integer N representing the number of days.
- Second line contains N space-separated integers representing the daily health improvement scores.
Output:
- Print the second maximum score among the N days.
Sample Input | Sample Output
8 | Second Maximum Score: 5
-3 4 6 -2 5 -7 3 4 |
[04]