Structured Programming
SWE · Quiz · Summer 25
Paper 2 of 2Section A · Batch 44 · Jobayer Ahmed Usamah - SWE (251) (2)Switch
Section A · Batch 44
Paper 2 of 2
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 3 (Set B)
Time: 30 mins
Full marks: 15
1. Declare a character variable and a string of size 5. Assign suitable values for both variables. 2
2. Analyze the following code to write the output when n = 5.
#include<stdio.h>
int main(){
int k, sum = 0, n;
printf("Enter the value of n\n");
scanf("%d", &n);
for(k=1; k<=n; k++){
sum += k;
printf("Sum at step %d is %d\n", k, sum);
}
printf("Final sum is %d\n", sum);
}
3. Identify the error(s), if any, in the following C code snippets and correct them: 1+2
a. char gpa
scanf("%c", gpa);
printf("%c", gpa);
b. char name[5];
name = 'Dhaka';
printf("%c", name)
4. Suppose, a 2D array of 3*3 dimension is given like below- 4
1 2 3
4 5 6
7 8 9
Develop a C code to replace the even numbers of the 2D array with * and odd numbers with @. Your final output will be like-
@ * @
* @ *
@ * @
5. Write a C program that takes user's country as input and prints the number of characters on it. 3
Sample Input:
Enter your country name: Bangladesh
Sample Output:
Length of your country name: 10