Lab3
Lab3
Objective:
i. Define problem specification.
ii. Convert Algorithm into C++ Program.
iii. Differentiate between string and char * data type.
iv. Compile and Execute/run program.
Instruction:
i. Open the Dev C++ program.
ii. Write C++ code for the questions given. (Task1-4)
iii. Find the output.
Task 1: Convert the following pseudo code into C++ program. Find the output.
To make a profit, a local store marks up the prices of its items by a certain percentage.
Write a C++ program that reads the original price of the item sold, the percentage of the
marked-up price and the sales tax rate. The program then outputs the original price of the
item, the percentage of the mark-up, the store’s selling price of the item, the sales tax rate,
the sales tax and the final price of the item.
1. Start
2. Num Original_price, Percentage_marked_up_price, sales_tax_rate,
Sales_tax, Final_price
3. Get Original_price, Percentage_marked_up_price, sales_tax_rate
4. Calculate selling price add with markup price.
Selling_price Original_price + (Original_price *
Percentage_marked_up_price)
Task 3: Convert the following pseudo code into C++ program. Find the output.
The program allowed user to read 3 positive integer numbers. Find the value for power of
two and power of three for each number. Calculate the total and average for all numbers.
Print the output.
1. Start
2. Num a, b, c, pTwo1, pTwo2, pTwo3, pThree1, pThree2, pThree3, total,
average
3. Get 3 positive numbers – a,b,c
4. Find power two for each number.
pTwo1 a * a
pTwo2 b * b
pTwo3 c * c
5. Find power of three for each number
pThree1 a *a *a
pThree2 b *b *b
pThree3 c *c *c
6. Calculate the total numbers
total a + b + c
7. Calculate the average of numbers
Average total / 3
8. Display pTwo1, pTwo2, pTwo3, pThree1, pThree2, pThree3, total and
average
9. End
Task 4: Write the following programs and shows the program output. Define
differentiate between a) and b).
a)
b)