Skip to content

Programming and Problem Solving

CSE · Midterm · Summer 25

Paper 1 of 3Batch 68 · Md. Karimul BasarSwitch

Batch 68

Paper 1 of 3

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 Faculty of Science & Information Technology Department of Computer Science & Engineering Mid Examination, Summer 2025 Course Code: CSE113, Course Title: Programming and Problem Solving Level: 1 Term: 2 Batch: 68 Time: 01:30 Hrs Marks: 25 Answer ALL Questions [Optional] [The figures in the right margin indicate the full marks and corresponding course outcomes. All portions of each question must be answered sequentially.] 1. Analyze the following problem and write what data types (int, float, char etc) and what programming concepts (Input/Output, Variables, Operators, If / else if / else, loop etc) are required to solve the problem. | CO1 a) A program needs to read 1000 characters, one by one. For each character, determine and print if it is a vowel (a, e, i, o, u) or a consonant. | 02 2. a) Please 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 <stdio.h> 2 3 int main() 4 { 5 int counter = 0; 6 int product = 1; 7 8 printf("Calculating product...\n"); 9 10 for (int i = 0; i < 4 i++) 11 { 12 product *= (counter + factor); 13 counter++; 14 } 15 16 printf("Final product: %d\n", product); 17 18 return 0; 19 } | 02 | CO2 b) Write a corrected version of the above program. | 02 3. Draw a flowchart to solve each of the following problems. | CO3 a) A taxi charges a BDT 50 base fare. It costs BDT 20/km for the first 10 km. For any distance beyond 10 km, the additional rate is BDT 15/km. Draw a flow chart to input the total distance of a trip. Then calculate and display the total fare. | 02 b) Calculate and print the factorial of a positive integer N provided by the user. If N is 0 or negative, display an appropriate error message instead. | 02 4. a) You are part of a team that is building a digital welcome board for CSE, DIU. Your task is to write a C program that will print 2 lines on the board when a new student stands in front of it. Your program should print a line containing "Welcome to CSE, DIU". Sample Input | Sample Output - | Welcome to CSE, DIU | 02 | CO3 b) You are developing a basic climate control system for a modern smart home. The system needs to decide what actions to take based on the current room temperature. | 02+ 02 i) Your first task is to implement a simple fan control. The program should ask the user to input the current room temperature (as an integer in Celsius). If the temperature is strictly greater than 25 degrees Celsius, the system should print "Temperature High: Fan ON". Otherwise it should print "Temperature OK: Fan OFF". Sample Input | Sample Output 30 | Temperature High: Fan ON ii) Your program ask the user to input current room temperature and desired room temperature (as an integer in Celsius). - If the current temperature is at least 50% more than the desired temperature, the system should print: "Cooling Mode: High Fan Speed" - Otherwise, if the current temperature is at least 20% more than the desired temperature, the system should print: "Cooling Mode: Moderate Fan Speed" - Otherwise, if the current temperature is more than the desired temperature, the system should print: "Cooling Mode: Low Fan Speed" - Otherwise the system should print: "Cooling Mode: No Cooling Needed" Sample Input | Sample Output 30 20 | Cooling Mode: High Fan Speed c) i) You have planted a small tree with 50 cm height besides the legendary jackfruit tree at DIU Kathaltola. The tree grows 2 cm each year. Your first task is to print the height of the tree at the end of each year from year 1 to year N where N is an integer that will be read from the user. | 02+02 Sample Input | Sample Output 5 | After year 1: 52 cm | After year 2: 54 cm | After year 3: 56 cm | After year 4: 58 cm | After year 5: 60 cm ii) A curious bird flies over your tree at a fixed height B (an integer read from the user) each year. If, at the end of any year, the bird's flying height B is not strictly greater than the tree's height, the bird hits the tree and stops flying. Your program receive two integer number (N) and height (B), calculate and print the total number of times the bird successfully completes its flight. Sample Input | Sample Output 5 56 | Bird completed 2 flights. Explanation of the sample: For the first part, the tree grows steadily for all 5 years. For the second part, the bird (flying at 56cm) completes 2 flights. At the end of year 3, the tree also reached 56cm, causing the bird to hit it and stop flying, resulting in 2 successful flights. d) i) You're helping a local weather station record daily high temperatures. Your task is to collect 10 daily temperature readings (in Celsius) from the user and store them in an array for analysis. After collecting the temperatures, print all the stored values, each on a new line, formatted to one decimal place. | 02+03 Sample Input | Sample Output 25.0 26.0 24.0 27.0 25.0 26.5 28.0 29.3 27.0 23.0 | Daily Temperatures: | 25.0 | 26.0 | 24.0 | 27.0 | 25.0 | 26.5 | 28.0 | 29.3 | 27.0 | 23.0 ii) The first line of input contains an integer N, representing the number of days. The second line contains N positive numbers, each representing the temperature recorded on a specific day. After listing the daily temperatures, calculate the average temperature. Then, count and print how many days had a temperature strictly above this average. Sample Input | Sample Output 10 | Days with above average 25.0 26.0 24.0 27.0 25.0 26.0 28.0 29.0 27.0 23.0 | temperature: 4 Explanation for sample I/O: The average temperature from the input data is 26.0 Celsius. Four days (27.0, 28.0, 29.0, 27.0) recorded temperatures strictly above this average.