Skip to content

Programming and Problem Solving

CSE · Quiz · Spring 26

Paper 6 of 6Section 70_L · Dewan Naim Islam (2)Switch

Section 70_L

Paper 6 of 6

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.

ID: Daffodil International University Course Code: CSE113 | Course Title: Programming & Problem Solving Section: 70_L | Time: 35 Minutes | Marks: 15 Quiz - 2 1. Consider the following C code and find out the syntax errors. You must also state [4] the reason for each error: 1 #include <stdio.h> 2 #include <string.h> 3 4 struct Data { 5 int id, char name[20]; int *ref; 6 } 7 8 int modify(struct data d, int x) { 9 *(d.ref) += x; 10 return (d_id + x) + *(d.ref); 11 } 12 13 int main() { 14 int val = 10; 15 struct Data d1 = {5, "Alpha", &val}, d2 = d1; 16 17 int r1 = modify(d1, 3); 18 int r2 = modify(*d2, -2); 19 20 printf("%d %d %d\n", r1, r2, d1.id, val); 21 return 0; 22 } 2. Consider the following C code and trace the output: [6] 1 #include <stdio.h> 2 3 int helper(int x) { 4 if (x <= 1) { 5 printf("helper(%d) -> base case\n", x); 6 return x + 1; 7 } 8 printf("helper(%d) calling helper(%d)\n", x, x - 2); 9 return helper(x - 2) + x; 10 } 11 12 int compute(int a, int b) { 13 printf("compute(%d, %d) called\n", a, b); 14 int p = helper(a); 15 int q = helper(b); 16 printf("p = %d, q = %d\n", p, q); 17 18 return p - q + helper(p - q); 19 } 20 21 int main() { 22 int x = 5, y = 4; 23 int ans = compute(x, y); 24 25 printf("%d\n", ans); 26 return 0; 27 } 3. A company wants to store and calculate the total salary of its employees. Each [5] employee has an ID, a basic salary, and years of experience. The company gives a bonus of 1500 Taka per year of experience. Write a C program using a structure to read the employee details and calculate the total salary the company needs to pay for the next month. Sample Input | Sample Output 3 | 164720 752001 57000 2 | 752002 63000 0 | 752001 40220 1 |