PAK GARRISON HIGHER SECONDARY SCHOOL
Housing Colony Nankana Sahib
Class: 2nd Year Computer Science Maximum Marks: 60
Student Name:
Roll Number: ___________ Date of Paper: 11-03-2025
_______________
Section: ___________ Paper Type: Programs + Output Time Allowed: 20min
Q1. Write detailed answers of the following questions. (5X10=50)
1. Write the a program that displays the first 15 even numbers.
2. Write a program that prints all odd positive integers less than 100 skipping those that are exactly divisible by 7.
3. Write down a program that produces the following output:
11
28
4 64
8 512
16 4096
32 32768
4. Write a program in C language that inputs a number, and displays its table according to the following for seemat:
Suppose the number entered is 5, the output will be as follows:
5*1=5
5*2=10
5*3=15
:
5*10=5
Q2. Write down short answers of following questions. (5X2=10)
[i] ـWhat is the output of the following code segment?
int x=3;
while(x<9)
{
printf("x is %d ",x);
x+=2;
}
[ii] ـPredict the output of the following piece of code.
int a=2;
while(a<=6)
{
printf(" a=%d",a);
a+=1;
}
[iii] ـHow many times the following loop display "welcome"?
for(i=12;i>0;i--)
printf("welcome");
[iv] ـTrace the output following code
n=0;
while(n<=4)
{
printf("%3d%3d ",n,10-n);
n++;
)
[v] ـDetermine output of following code:
int i;
i=10;
while (i<=10) {
printf (" %d", i);
i++;
}