Professional Documents
Culture Documents
Abdul Rehman PF
Abdul Rehman PF
Programming Fundamentals
Name: Abdul Rehman Roll Num: 70131431
1. Design an algorithm to convert the change given in quarters, dimes, nickels, and
pennies into pennies. Also write a C++ code and show the output.
#include <iostream>
int main ( )
{
float userNumber;
int change, quarters, dimes, nickels, pennies;
cout <<"Enter the amount of money: ";
cin >> userNumber;
change = userNumber * 100;
quarters = change / 25;
change = change % 25;
dimes = change / 10;
change = change % 10;
nickels = change / 5;
pennies = change ;
return 0;
}
Pseudocode:
Print “Enter the amount of money: ” and then store input in UserNumber.
Assign ‘userNumber * 100’ to change. Assign ‘change / 25’ to quarters. Assign ‘change % 25’ to change.
area_of_pizza=3.14*radius*radius;
price=price_of_pizza/area_of_pizza;
return 0;
Pseudo Code:
Declare radius, price_of_pizza as ints. area_of_pizza and price as doubles.
Print “Enter the radius of the pizza:” and store the input in price_of_pizza.
Print price.
Assignment # 1
3. To make a profit, the prices of the items sold in a furniture store are
marked up by 80%.
After marking up the prices each item is put on sale at a discount of
10%. Design an
algorithm to find the selling price of an item sold at the furniture store.
What information do
you need to find the selling price? Also write a C++ code and show the
output.
#include <iostream>
using namespace std;
int main()
{
double a,b,z,s;
cout<<"Enter the original price : "<<
cin>>a;
b=a+(a*0.8);
z=b*0.1;
s=b-z;
cout<<"Original Price : "<<a<<endl;
cout<<"Selling Price : "<<s;
return 0;
}
#include <iostream>
int main()
{
int secElapsed, hours, min, sec;
cout << hours << ":" << min << ":" << sec << endl;
return 0;
}
Display hours:min:sec.
Assignment # 1
#include<iostream>
#include <iomanip>
using namespace std;
int main()
{
int TestScore[4];
double WeightedScore[4];
Declare all testscores as ints and all the weighted scores as doubles.
Calculate weighted score using the formla and print the result.
Assignment # 1