0% found this document useful (0 votes)
64 views3 pages

Lab3

The document provides instructions for a lab assignment on string type and string manipulation in C++. It includes 4 tasks: 1) write a program to calculate final price of an item including original price, markup percentage, sales tax rate, sales tax amount, and final price; 2) write a program to calculate the area of shaded regions in diagrams; 3) write a program that takes 3 positive numbers as input, calculates the square and cube of each, and outputs total, average, and results; 4) write 2 programs using string and char* data types and explain the difference between them.

Uploaded by

Athifa Rufaida
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
64 views3 pages

Lab3

The document provides instructions for a lab assignment on string type and string manipulation in C++. It includes 4 tasks: 1) write a program to calculate final price of an item including original price, markup percentage, sales tax rate, sales tax amount, and final price; 2) write a program to calculate the area of shaded regions in diagrams; 3) write a program that takes 3 positive numbers as input, calculates the square and cube of each, and outputs total, average, and results; 4) write 2 programs using string and char* data types and explain the difference between them.

Uploaded by

Athifa Rufaida
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

LAB 4: string Type and string Manipulation

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)

5. Calculate sales tax


Sales_tax  sales_tax_rate * selling_price

6. Calculate final price of the item


Final_price  Selling_price + Sales_tax

7. Display Original_price, Percentage_marked_up_price, Selling_price,


Sales_tax_rate, Sales_tax and Final_price
8. End
Task 2: For the following diagrams, write a program to determine the area of
the shaded part.

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)

You might also like