Skip to content

Structured Programming

SWE · Quiz · Summer 25

Paper 1 of 2Section A · Batch 44 · Jobayer Ahmed Usamah - SWE (251) (1)Switch

Section A · Batch 44

Paper 1 of 2

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.

Course code: SE121, Course title: Structured Programming Section A - Class Test 2 (Set A) Time: 30 mins Full marks: 15 1. Which loop is best suited when the number of iterations is known in advance? 1 a) while b) do-while c) for d) if-else 2. What will be the output of the following code? 1 int i=0; while(i<=5) printf("%d", ++i); a) 1 2 3 4 5 b) 0 1 2 3 4 c) 1 2 3 4 d) None of the above 3. Write a C statement to declare a one-dimensional array of size 5. What will be the index of the first element of the array? 2 4. Identify the error(s), if any, in the following C code snippets and correct them: 4 a. int i = 1; while (i < 5); printf("%d", i); b. int arr[5] = {1, 2, 3, 4, 5}; int sum = 0; for(int i = 0; i <= 5; i++) { sum += arr[i]; } printf("Sum = %d", sum); 5. Based on the marks (out of 15) obtained in Class Test 1, I would like to provide feedback using a grade scale (A–C) as follows: A: You are a true learner (11-15). B: Passed, but needs improvement (6-10). C: Failed (0-5). For any other input, the default message should be: "Unknown." Write a C program that implements the above scenario using a switch-case statement. 3 6. Write a for loop to print all even numbers from 1 to 20. 4