0% found this document useful (0 votes)
5 views3 pages

PPS Fall2022 Final

Uploaded by

efaz444ahmed
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views3 pages

PPS Fall2022 Final

Uploaded by

efaz444ahmed
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

Daffodil International University

Department of Computer Science and Engineering


Faculty of Science & Information Technology
Final Examination, Fall 2022
Course Code: CSE122 (Day), Course Title: Programming & Problem Solving
Sections, Teachers & Campus: All
Time: 2:00 Hrs Marks: 40

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 a Show the errors in the following code and rewrite the full code after correction. 5 CO
. ) #include<stdio.h> 2
struc student
{
int id;
char name[20];
float cgpa;
}s={1,"Kashem",3.50},p=&s;
int main()
{
printf("%d %s %f",p->id,s->name,(*p).cgpa);
return 0;
}

2 Build output for each of the following program


. a #include<stdio.h> 2.5 CO
) int main() 3
{
int i=6,*j,k;
j=&i;
printf("%d",i**j*i+*j);
return 0;
}
b #include<stdio.h> 2.5
) int recursive(int n){
if(n==0) return 1;
return 2*recursive(n-2);
}
int main( ){
int value=6;
int result=recursive(value);
printf("Result = %d",result);
return 0;
}

Page 1 of 3
3 Discover a full C Program for each of the following problems and write them: CO
. 4
a Dia has started programming using arrays recently. She knows how to take input 6
) in an array and display the elements of that array. But she doesn't know how to
display the array elements in reverse order. Now write a program to help her by
displaying array elements in reverse order.
Sample Input Sample Output
Enter how many elements: Elements in reverse order:
6 30 10 60 100 50 20
The entered elements are:
20 50 100 60 10 30

b DIU CPC team members started playing a game called “hello world”. A judge 6
) will give a sequence containing characters a to z. You have to count the number of
hello in the given sequence of sentences.

Sample Input Sample Output


hello mr. hafiz. hello how are you? 3
hello i’m fine.

c Given two numbers you have to write a full program to Swap those numbers 6
) using Function.

Sample Input Sample Output

Before swapping: After swapping:


n1 = 122, n2 = 123 n1 = 123, n2 = 122

d Students of 1st semester have already learned about pyramids. There are different 6
) patterns of pyramids which have been illustrated by mathematicians. While
studying, they came to know about the following pyramids and the right handed
outputs have been calculated from input N=5 (where, 0<N<=100).
Sample Input Sample Output
5 0
0 1
0 2 4
0 3 6 9
0 4 8 12 16

e A problem solver has provided you the following sequence: 6


) 1 1 2 3 5 8 13 21 34 55
First two numbers are given as 1 & 1. Rest of the numbers are being counted by
summation of previous two numbers.
Now write a full C program using recursion to find the series of numbers from
the given sequence.
Input: An Integer N (0 < N < 100).
Output: Nth number from the given sequence.

Page 2 of 3
Sample Input Sample Output
10 1 1 2 3 5 8 13 21 34 55

Page 3 of 3

You might also like