You are on page 1of 8

NAME: ABDULLAH KHAN RAJA

REGISTRATION NO :BCS231095

ASSIGNMENT

QUESTION NO.01
#include <iostream>
#include <conio.h>
using namespace std;
int main()
{
int employee1 = 1, employee2 = 2, n;
float netpay,grosspay, tax = 40, IRA = 10, deduction;
cout << "Please press 1 for 1st Employee: \n";
cout << "Please press 2 for 2nd Employee: \n";
cin >> n;
if (employee1 == n)
{
grosspay = 16.43 * 20;
cout << "The gross pay amount of employee is: \n"
<< "$" << grosspay << endl;
deduction = tax + IRA;
netpay = grosspay - deduction;
cout << "The net pay of employee is: \n"
<< "$" << netpay << endl;
}
else if (employee2 == n)
{
grosspay = 12.67 * 20;
cout << "The gross pay amount of employee is: \n"
<< "$" << grosspay << endl;
deduction = tax + IRA;
netpay = grosspay - deduction;
cout << "The net pay of employee is: \n"
<< "$" << netpay << endl;
}
else
{
cout << "Pardon me but the entered valued are invalid,enter 1 or 2 only\n";
}

}
OUTPUTS FOR QUESTION 1
QUESTION NO. 02
#include <iostream>
using namespace std;
int main()
{
float t = 20, d = 14, initialspeed = 50;
float s,distance;
s = initialspeed / 3600 ;
distance = s * t - (1 / 2) * d * t * t ;
cout << "Since the car traveled after 20 second so the distance will be : \n"
<< distance << " Miles Per Second(mps)" << endl;

OUTPUTS FOR QUESTION NO.02


QUESTION NO. 03
#include <iostream>
using namespace std;
int main()
{

char n;
cout << "PLEASE ENTER A CHARACTER" << endl;
cin >> n;
switch (n)
{
case 'a':
cout << "Option A is selected" << endl;
break;
case 'b':
cout << "Option B is selected" << endl;
break;
case 'c':
cout << "Option C is selected" << endl;
break;
case 'd':
cout << "Option D is selected" << endl;
break;
default:
cout << "Invalid option selection" << endl;
break;
}
}

OUTPUTS FOR QUESTION 3


QUESTION NO.04

#include <iostream>
using namespace std;
int main()
{
int x;
char variables;
cout << "Enter an INTEGER ";
cin >> x;

cout << "Enter a to calculate number of Even numbers in the range"<<endl;


cout << "Enter b to calculate the sum of odd numbers in the range "<<endl;
cin >> variables;
switch (variables)
{
case 'a':
{
int even = 0;
for (int i = 1; i < x; i++)
{
if (i % 2 == 0)
{
even++;
}
}
cout << "Number of even number/s in the range: " << even << endl;
break;
}
case 'b':
{
int odd = 0;
for (int i = 1; i < x; i++)
{
if (i % 2 != 0)
{
odd += i;
}
}
cout << "The Sum of odd number/s in the range: " << odd << endl;
break;
}
default:
cout << "Invalid Entry" << endl;
break;
}
}
OUTPUT FOR QUESTION NO. 4
QUESTION NO.05

#include <iostream>
using namespace std;

int main()
{
int X, c, y;
cout << "Enter any positive number: ";
cin >> X;
cout << "Multiplication table for 1 to " << X << " is as follows:" << endl;
for (int c = 1; c <= X; c++)
{
for (int y = 1; y <= X; y++)
{
int product = c * y;
cout << product << "\t";
}

cout << endl;


}

return 0;
}

OUTPUT FOR QUESTION NO.05

You might also like