United International University (UIU)
Dept. of Computer Science & Engineering (CSE)
Final Exam:: Trimester: Summer 2022
Course Code: CSE 1111, Course Title: Structured Programming Language
Total Marks: 40 Duration: 2 hours
[Any examinee found adopting unfair means will be expelled from
the trimester/program as per UIU disciplinary rules.]
There are FIVE questions. Answer all the questions. Marks are indicated in the right margin.
Q.1 a) Write the output of the following code, if the user inputs are 1,2,3,4,5,6,7,8,9,10,.. sequentially. [4]
#include <stdio.h>
void main(){
int i, j, data[5][5]={0};
for(i=0; i<5; i++) {
for(j=i+1; j<5; j++)
scanf("%d", &data[i][j]);
}
for(i=0; i<5; i++) {
for(j=i; j<5; j++)
printf("%d_", data[i][j]);
printf("\n");
}
}
b) Write a program that will take integer inputs into an m x n matrix, where m and n should be input [4]
by the user. Now reverse the matrix within itself. Reversal means swap 1st column with the nth
column, swap 2nd column with the (n-1)th column and so on.
Sample input 1 Sample output 1 Sample input 2 Sample output 2
123 321 123456 654321
456 654 987654 456789
292 292
Q.2 a) Find out the output of the following program. [4]
#include<stdio.h>
int func(int n){
printf("%d\n", n);
if(n%7==0) return 2;
else if(n%2==0) func(n+2);
else func(n+1);
printf("%d\n",n);
}
void main(){
printf("%d", func(3));
}
b) Mr. Y is having a wonderful LaLiga season. He is scoring goals in almost each match. He has [4]
appointed you to calculate the statistics of this season. Now, write a c program based on the
following requirements:
i. Write a function inputData(int goals[ ], int mins[ ], int n), where n is the number of matches
played; goals and mins arrays store the number of goals scored and minutes played for all
the matches.
ii. Write a function countOfHattricks(int goals[ ], int n), which will find and return the number of
hattricks (3 or more than 3 goals in a match) the player scored in n number of matches.
iii. In the main() function, declare and initialize the variables and arrays as needed. Also, call
each function at least once.
Q.3 a) Rahim is suffering from stuttering. Stuttering / stammering is a speech disorder, which causes [4]
involuntary repetitions of vowels, phrases, etc. Write a program that will take a sentence said
by Rahim and store that into a string. The program will also correct the sentence by removing the
repetitive vowels.
Sample input string Sample output string
He is aaaa smaart boy. He is a smart boy.
IIIIIII will geeeeet great maarks. I will get great marks.
Page 1 of 2
Q.3 b) Show manual tracing (every change) of variables i, k, str1, and str2 of the following code [4]
segment.
char str1[50]={'\0'}, str2[50]="BEST";
strcpy(str1, "HELLO FELLAS");
int i= strlen(str1) * 0.5;
for(int k=0; str2[k] != '\0'; ++k)
str1[i+k]=str2[k];
strrev(str1);
strcat(str1, str2);
if(strcmp(str2, str1)>0){
strcpy(str1, "CSE IS EASY");
}else{
strcpy(str2, “UIU IS THE BEST");
}
Q.4 Write a program that will store the following information of international cricket bowlers: [8]
a) Total wickets taken, b) Total matches played, c) Total runs conceded, d) Name &
Country of the bowler, e) Average of the bowler.
Use appropriate data types and variable names for all the features. The program will also have
the following functionalities:
i. Take input for 100 bowlers from the users. Do not take input for average of the
bowlers.
ii. For each bowler, calculate the average and store it. The average of a bowler is the
total runs conceded divided by the total wickets taken.
iii. Find and print all the information of the bowler that has the maximum average.
Q.5 a) Show the output of the following program: [4]
void f1(int *arr, int n){
for (int i = 0; i < n; i++) {
if (*(arr + i) % 2 != 0) {
printf("-%d-\n", *(arr + i)+i*2);
}
}
}
int main(){
int arr[] = {2, 3, 6, 7, 11, 8};
f1(arr, 6);
}
b) Write a program that reads the “numbers.txt” file (See the “numbers.txt” file below) that has [4]
integer numbers on separate lines in ascending order and computes the median of the numbers.
The median of a number is defined by the middle value of a list of sorted numbers.
1
2
3
4
5
6
7
8
9
10
numbers.txt
Page 2 of 2