IT Final (Approved)
IT Final (Approved)
Question # 2 [Q Marks-10]
a) Remove programming/ syntax errors from the following. [4 marks]
int a,b;
cin<<a;
b=a;
cout <<"b=",a;
};
#include “iostream”
int main()
const PI=3.14;
int r,h;
cin>>r,h;
v=PI*r*r*h;
b) What is the output when the following code and explain the output at their respective steps? [6]
CODE OUTPUT
include<iostream>
using namespace std;
int main()
{
int num1=100, num2=200;
cout << "number 1 is " <<
num1 <<"\t" << "number 2 is" << num2 <<
"\n" ;
if (num1 <= 100)
{
num1 += num2;
num2 += num1;
}
else
{
num2 -= 20;
num1 -= num2;
}
if (num2 <= 200)
{
num2 -= num1;
num1 -= num2;
}
else
{
num1 -= 100;
num2 -= num1;
}
cout << num1 <<"\n";
cout << num2;
system("pause");
return 0;
}
Question # 3 [Q Marks-5]
How does C++ program works? Explain each step with the help of figure.
The software engineer usually travels from Rawalpindi railway station to rest of the cities. For traveling to the
following cities software engineer can select any one of the categories:
1. Rawalpindi to Lahore
a. Executive Class
b. Lower A/C
c. Economy
2. Rawalpindi to Karachi
a. Executive Class
b. Lower A/C
c. Economy
d. First Class Sleeper
e. Economy Sleeper
3. Rawalpindi to Quetta
a. First Class Sleeper
b. Economy Sleeper
4. Rawalpindi to Peshawar
a. Executive Class
b. Lower A/C
c. Economy
User can choose any of the above mentioned choices to go to different cities. From these choices further he can
choose what sort of bogie he wants. Each bogie has its own respective price. Once passenger has chosen the bogie.
This price also has 15% of tax which has to be included. Define the price for different bogies and destination by
yourself.
Develop a flow chart showing the total bill to be paid (including 15% tax). The program should work such that if
the user selects the destination, the price should be displayed.
Question #7 [Q Marks-10]
Write a C++ program that reads marks of a class (having 5 students) from the user and places them in an array of
type float. After that, it should compute average marks obtained by the class. In the end, display student number
and their marks for all those students who got marks above average.
Question # 9 [Q Marks-10]
Design a program in C++ to display the calendar of a following month using multiple for loops.
NOVEMEBER 2019
Mon Tue Wed Thu Fri Sat Sun
1 2 3 4 5 6 7
8 9 10 11 12 13 14
15 16 17 18 19 20 21
22 23 24 25 26 27 28
29 30