PPS Fall2022 Final
PPS Fall2022 Final
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;
}
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.
c Given two numbers you have to write a full program to Swap those numbers 6
) using Function.
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
Page 2 of 3
Sample Input Sample Output
10 1 1 2 3 5 8 13 21 34 55
Page 3 of 3