You are on page 1of 3

ABDULLAH KHAN RAJA

BCS231095
QUIZ 8

QUESTION 1:
CODE 1:
#include <iostream>
using namespace std;

double Sale_Price(double purchasePrice, double taxRate) {


double taxAmount = purchasePrice * (taxRate / 100);
double salePrice = purchasePrice + taxAmount;
return salePrice;
}

int main()
{
double purchasePrice, taxRate;
cout << "Enter the purchase price: ";
cin >> purchasePrice;
cout << "Enter the tax rate: ";
cin >> taxRate;

double finalPrice = Sale_Price(purchasePrice, taxRate);


cout << "Sale price: " << finalPrice << endl;

return 0;
}

OUTPUT:

QUESTION 2:
CODE 2:
#include <iostream>
using namespace std;

void printDiamond(int& n) {
int i, j, space;

for (i = 1; i <= n; ++i) {


for (space = 1; space <= n - i; ++space) {
cout << " ";
}
for (j = 1; j <= 2 * i - 1; ++j) {
cout << "*";
}
cout << std::endl;
}

for (i = n - 1; i >= 1; --i) {


for (space = 1; space <= n - i; ++space) {
std::cout << " ";
}
for (j = 1; j <= 2 * i - 1; ++j) {
cout << "*";
}
cout << std::endl;
}
}

int main() {
int size;
cout << "Enter the size of the diamond: ";
cin >> size;

printDiamond(size);

return 0;
}

OUTPUT:

You might also like