University of The Punjab
University of The Punjab
University of The Punjab
https://www.facebook.com/HussainSajidOfficial http://tea.net.pk/
[email protected]
int i = 1;
while true {
cout<<i;
if i==5 {
break;
}
i++;
}
A Forever B 5 times
C 6 times D 0 times
E None of the above
10 What does the following piece of code print?
for int i = 0; i < 3; i++ {
for int j = 5; j < 7; j++ {
cout<<'*';
}
cout<<endl;
}
A ** B ***
** ***
**
C ****** D*
**
Q.2: Give brief answer to the following questions. (Short Questions) Marks: (10 x 2 = 20)
https://www.facebook.com/HussainSajidOfficial http://tea.net.pk/
[email protected]
9. Define nested if statement and also give an example.
10. Define function and its benefits.
Q.3: Give detail answer to the following questions. (Long Questions) Marks: (10 x 3 = 30)
1. State important features of object oriented program. Compare object oriented programming
with procedure oriented programming.
2. Difference between abstraction and encapsulation with detail example in your own words.
3. Write an algorithm to print table from 2 to 10:
2x1=2
2x2=4
. . .
. . .
3x1=3
3x2=6
. . .
. . .
https://www.facebook.com/HussainSajidOfficial http://tea.net.pk/
[email protected]