You are on page 1of 5

HASSAN RASIF

O2-235222-014
CP LAB 08

EXERCISE 01;

#include <iostream>
using namespace std;
int addition(int a, int b, int &c) {
c = a + b;
return c;
}
int substraction(int a, int b, int &c) {
c = a - b;
return c;
}
float division(int a, int b, float &c) {
c = (float)a / (float)b;
return c;
}
float multiplication(int a, int b, int &c) {
c = a*b;
return c;
}

int main() {
int num1, num2;
int r1, r2, r3;
float r4;

cout << "Enter the first number:\n";


cin >> num1;
cout << "Enter the second number:\n";
cin >> num2;
cout << "Your desired answer is: " << addition(num1,
num2, r1) << endl;
cout << "Your desired answer is: " << substraction(num1,
num2, r2) << endl;
cout << "Your desired answer is: " << division(num1,
num2, r4) << endl;
cout << "Your desired answer is: " <<
multiplication(num1, num2, r3) << endl;
HASSAN RASIF
O2-235222-014
CP LAB 08
system("pause");

Exercise 03;
#include<iostream>
using namespace std;
void apple(int apple_per_kg, int a, int &apple1)
{
apple1 = apple_per_kg * a;
return;
}
void banana(int banana_per_kg, int b, int &banana_1)
{
banana_1 = banana_per_kg * b;
return;
}
void mango(int mango_per_kg, int m, int &mango_1)
{
HASSAN RASIF
O2-235222-014
CP LAB 08
mango_1 = mango_per_kg * m;
return;
}
void peach(int peach_per_kg, int p, int &peach_1)
{
peach_1 = peach_per_kg * p;
}
void grapes(int grapes_per_kg, int g, int &grapes_1)
{
grapes_1 = grapes_per_kg * g;
return;
}
void cabbage(int cabbage_per_kg, int g, int &cabbage_1)
{
cabbage_1 = cabbage_per_kg * g;
return;
}
void tomatoes(int tomatoes_per_kg, int g, int &tomatoes_1)
{
tomatoes_1 = tomatoes_per_kg * g;
return;
}
int main()
{
int a, b, m, p, g, apple_pr_kg = 280, banana_pr_kg =
200, mango_pr_kg = 300, grapes_pr_kg = 200, peach_pr_kg =
100, cabbage_pr_kg = 80, tomatoes_pr_kg = 80, apple1,
banana1, mango1, peach1, grapes1, cabbage1, tomatoes1,
total;
cout << "##########################################" <<
endl;
cout << "How many Apple do you want : ";
cin >> a;
cout << "How many Banana do you want : ";
cin >> b;
cout << "How many Mango do you want : ";
cin >> m;
cout << "How many Peach do you want : ";
cin >> p;
HASSAN RASIF
O2-235222-014
CP LAB 08
cout << "How many Grapes do you want: ";
cin >> g;
apple(apple_pr_kg, a, apple1);
banana(banana_pr_kg, b, banana1);
mango(mango_pr_kg, m, mango1);
peach(peach_pr_kg, p, peach1);
grapes(grapes_pr_kg, g, grapes1);
cout << "==================================" << endl;
cout << "Pries of Apple: " << a << " * " << apple_pr_kg
<< " = " << apple1 << endl;
cout << "Pries of Banana: " << b << " * " <<
banana_pr_kg << " = " << banana1 << endl;
cout << "Pries of Mango: " << m << " * " << mango_pr_kg
<< " = " << mango1 << endl;
cout << "Pries of Peach: " << p << " * " << peach_pr_kg
<< " = " << peach1 << endl;
cout << "Pries of Grapes: " << g << " * " <<
grapes_pr_kg << " = " << grapes1 << endl;
cout << "******************************************" <<
endl;
total = apple1 + banana1 + mango1 + peach1 + grapes1;
cout << "Total prices of your purchase is " << total <<
endl;
cout << "#########" << endl;
return 0;
}
HASSAN RASIF
O2-235222-014
CP LAB 08

You might also like