You are on page 1of 7

NAME : FAIZAN BAHADUR

ROLL NUM : 23-CS-142

Programming Fundamentals

➢ Lab Manuals 1

Task -1
using namespace std;
int main()
{
double costPrice, markedUpPrice, discountedPrice, sellingPrice;
cout << "Enter the cost price of the item: ";
include<iostream>
cin >> cost Price;
#markedUpPrice = costPrice * 1.8;
discountedPrice = markedUpPrice * 0.9;
sellingPrice = discountedPrice;
cout << "Selling Price: $" << sellingPrice << endl;
return 0;
}
OUTPUT:

Task -2
#include<iostream>
#include<cmath>
using namespace std;
int main() {
double a, b, c, s, area;
cout << "Enter the length of side a: ";
cin >> a;
cout << "Enter the length of side b: ";
cin >> b;
cout << "Enter the length of side c: ";
cin >> c; s = (a + b + c) / 2;
area = sqrt(s * (s - a) * (s - b) * (s - c));
cout << "Area of the triangle: " << area << endl;

OUTPUT:

Task -2
#include<iostream>
using namespace std;
int main() {
// Variables
int numItems;
double pricePerItem, totalCost, shippingCost,
totalBillingAmount; cout << "Enter the number of items
ordered: ";
cin >> numItems;
cout << "Enter the price of each item: ";
cin >> pricePerItem;
totalCost = numItems * pricePerItem;
if (totalCost >= 200) {
shippingCost = 0;
} else {
shippingCost = 10 * numItems;
}
totalBillingAmount = totalCost + shippingCost;
cout << "Total Billing Amount: $" << totalBillingAmount << endl;
return 0;
}
TASK -4
#include<iostream>
using namespace std;
int main() {
// Constants
const double serviceCharge = 3.00;
const double perPageRateFirst10 = 0.20;
const double perPageRateAdditional = 0.10;
const int first10Pages = 10; // Variables
int numPages;
double amountDue;
// Input
cout << "Enter the number of pages to be faxed: ";
cin >> numPages;
if (numPages <= first10Pages) {
amountDue = serviceCharge + numPages * perPageRateFirst10;
} else {
amountDue = serviceCharge + first10Pages *
perPageRateFirst10 + (numPages -
first10Pages) * perPageRateAdditional;
}
cout << "Amount Due: $" << amountDue << endl;
return 0;
}
OUTPUT:

You might also like