Programming and Problem Solving
CSE · Midterm · Spring 26
Paper 3 of 5Batch 70 · RAIYANSwitch
Batch 70
Paper 3 of 5
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, Spring 26
Course Code: CSE113, Course Title: Programming and Problem Solving
Level: 1 Term: 2 Batch: 70
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 group all the operators support in C language. | [02] | CO1
#include <stdio.h>
int main() {
int a = 6, b = 4, c = 2;
int result;
result = a * b + c;
result += (a > b) ? a : b;
if ((result % 2 == 0) && (c != 0))
result = ++result;
else
result = --result;
printf("Final Result: %d\n", result);
return 0;
}
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 <stdio.h>
2. int main() {
3. int marks[5] = {65, 72, 88, 54, 90
4. int i;
5. for i = 0, i < 5, i++ {
6. if marks[i] > 70 {
7. printf("Student %d scored above 70\n", i+1)
8. } else
9. printf("Student %d scored 70 or below\n", i+1);
10. }
11. return 0;
12. } | [02] | CO2
2. b) | Write a corrected version of the above program. | [02]
3. a) | Draw a flowchart to solve each of the following problems.
New grading system introduces at DIU; students get a grade based on their marks in a course:
- Marks < 50 -> Grade F
- Marks between 50 and 59 -> Grade D
- Marks between 60 and 69 -> Grade C
- Marks between 70 and 79 -> Grade B
- Marks 80 or above -> Grade A
Task:
Draw a flowchart that takes a student's marks as input, determines the grade based on the above rules, and outputs the student's grade. | [02] | CO3
3. b) | At the DIU Green Garden, a student can buy snacks multiple times. The student can continue ordering until: They reach a total spending limit of 500 BDT. The program should calculate the total bill while checking the condition.
Task:
Draw a flowchart that inputs the snack price each time, adds it to the total bill, and stops when the student chooses to stop or reaches the spending limit. Then display the total amount. | [02]
4. a) | Identify the problem scenarios given below and write a complete C program for each problem statement.
You are working on an equipment management system for the DIU ACM Lab. Each computer requires a fixed number of network cables, and a lab has multiple computers. Write a C program that takes the number of computers and the number of cables required per computer as input and displays the total number of cables needed.
Input:
- First line contains two integers separated by space representing the number of computers and cables per computer.
Output:
- Print the total number of cables required.
Sample Input | Sample Output
123 11 | Total cables required: 1353 | [03] | CO4
4. b) | You are developing a lab access control system for the CSE Department at DIU. A student is allowed to enter the ACM Lab based on attendance percentage and quiz score.
Rules:
- If attendance >= 75 and quiz score >= 50 -> Access Granted
- If attendance >= 75 but quiz score < 50 -> Quiz Score Too Low
- If attendance < 75 -> Attendance Shortage
Write a C program that takes attendance percentage and quiz score as input and displays the appropriate message.
Input:
- First line contains two integers representing attendance percentage and quiz score.
Output:
- Print the access status message.
Sample Input | Sample Output
80 35 | Quiz Score Too Low | [03]
4. c) | You are developing a display system for the DIU ACM Lab that shows student practice status for the CSE Department. The system displays numbers from 1 to N, but replaces certain numbers with special labels based on the following rules:
- If the current number is divisible by 3, print DIU
- If the current number is divisible by 4, print CSE
- If the current number is divisible by both 3 and 4, print DIU-CSE
- Otherwise, print the number itself
Write a C program that takes an integer N as input and prints the output from 1 to N using a single loop.
Input:
- First line contains an integer N.
Output:
- Print the values from 1 to N following the given rules, each on a new line.
Sample Input | Sample Output
6 | 1
2
DIU
CSE
5
DIU | [03]
4. d) | During a programming contest at the DIU ACM Lab, organizers want to display a triangle pattern on the screen representing the contest difficulty levels. Write a C program that takes an integer N and prints a complete triangle pattern using *.
Input:
- First line contains an integer N representing the number of rows.
Output:
- Print the complete triangle pattern.
Sample Input | Sample Output
4 | *
***
*****
******* | [03]
4. e) | You are building a performance analysis system for the CSE Department at Daffodil International University (DIU). The system stores the lab marks of students and analyzes their performance.
Write a C program that takes N lab marks as input and performs the following tasks:
- Count how many students have passed the lab exam (marks >= 40).
- Calculate the average marks of the class.
- Count how many students passed the exam but scored below the class average.
Input:
- First line contains an integer N representing the number of students.
- Second line contains N integers representing lab marks.
Output:
- First line prints the number of students who passed.
- Second line prints the number of students who passed but scored below the average marks.
Sample Input | Sample Output
5 | Passed students: 4
35 40 55 45 60 | Passed but below average: 2 | [03]