You are on page 1of 2

TALHA MAQSOOD MID TERM PAPER

02-134182-080 COMPUTER PROGRAMMING LAB

Question # 01:

Source code
#include <iostream>
using namespace std;
int main()
{
{
int i , j ,limit, act[limit] ;
float sum;
cout<< "ENTER a limit till where you want to get sum : ";
cin >> limit;
cout<< "1";
for ( i = 2 ; i <= limit ; i++ )
{
cout << " + "<< "1/"<<i ;
}

cout <<" = ";


for ( i = 1 ; i <= limit ; i++ )
{
sum = sum + ( 1/i );
}
cout << sum;

return 0;
}
TALHA MAQSOOD MID TERM PAPER
02-134182-080 COMPUTER PROGRAMMING LAB

Question # 01:

Source code
#include <iostream>
#include <string>
using namespace std;
int main()
{
int i , j ;
int place ;

cout<< "YOUR DESTINATION\n";


cout<< "where your want to go\n\nPress\n ";
cout<<"1 for bombay\n2 for karachi\n3 for hyderabad\n4 for multan\n5 for lahore\n\n";

cin>> place;

if (place == 1 )
{
cout <<"cost is 1000"; }
else if (place ==2 )
{ cout <<"cost is 700"; }
else if (place ==3 )
{ cout <<"cost is 600"; }
else if (place ==4 )
{ cout <<"cost is 400"; }
else if (place ==5 )
{ cout <<"cost is 1200"; }

return 0;
}

You might also like