100% found this document useful (1 vote)
708 views11 pages

C Programming: Algorithms & Flowcharts

The document provides 10 programming problems with algorithms and flowcharts to solve each problem. The problems include calculating the volume of a sphere, converting between Celsius and Fahrenheit, currency conversion, and calculating the radius of a circle from its area. For each problem, it lists the steps in the algorithm and draws the corresponding flowchart. It then provides the code to implement the solution to each problem.

Uploaded by

agnes joshy
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
100% found this document useful (1 vote)
708 views11 pages

C Programming: Algorithms & Flowcharts

The document provides 10 programming problems with algorithms and flowcharts to solve each problem. The problems include calculating the volume of a sphere, converting between Celsius and Fahrenheit, currency conversion, and calculating the radius of a circle from its area. For each problem, it lists the steps in the algorithm and draws the corresponding flowchart. It then provides the code to implement the solution to each problem.

Uploaded by

agnes joshy
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
  • Q1: Volume of Sphere
  • Q2: Celsius to Fahrenheit
  • Q3: Currency Conversion (Dollar to Peso)
  • Q4: Inches to Centimeters
  • Q5: Swap Variables
  • Q6: Circumference of a Circle
  • Q7: Depreciation Calculation
  • Q8: Swap Without Temporary Variable
  • Q9: Economic Order Quantity
  • Q10: Radius of a Circle from Area

Solved Assignment Problems in C (with Algorithm and Flowchart)

Q1. Create a program to compute the volume of a sphere. Use the formula: V = (4/3) *pi*r3 where pi is equal to 3.1416 approximately. The r is the
radius of sphere. Display the result.

Algorithm Flowchart Program

1. Start Start
2. Read r
3. vol = (4/3) *pi*r*r*r
4. Print or display vol
5. Stop Read r

vol = (4/3) *pi*r*r*r

Write vol

Stop

1 |Page
Q2. Write a program the converts the input Celsius degree into its equivalent Fahrenheit degree. Use the formula: F = (9/5) *C+32.

Algorithm Flowchart Program

1. Start Start
2. Initialize F=0, C=0
3. Read C
4. Fh = (1.8*C) + 32 C=0, F=0
5. Print or display Fh
6. Stop

Read C

Fh = (1.8*C) + 32

Write Fh

Stop

2 |Page
Q3. Write a program that converts the input dollar to its peso exchange rate equivalent. Assume that the present exchange rate is 51.50 pesos against
the dollar. Then display the peso equivalent exchange rate.

Algorithm Flowchart Program

1. Start
2. Read dollar Start
3. peso = dollar * 51.50
4. Print or display peso
5. Stop Read dollar

peso = dollar * 51.50

Write peso

Stop

3 |Page
Q4. Write a program that converts an input inch(es) into its equivalent centimeters. Take note that one inch is equivalent to 2.54cms

Algorithm Flowchart Program

1. Start
Start
2. Read inch
3. cm = 2.54 * inch
4. Print or display cm
Read inch
5. Stop

pcm = 2.54 * inch

Write cm

Stop

4 |Page
Q5. Write a program that exchanges the value of two variables: x and y. The output must be: the value of variable y will become the value of
variable x, and vice versa.

Algorithm Flowchart Program

1. Start
2. Read x, y Start
3. Declare third variable, z
z=x
x=y Read x, y
y=z
4. Print or display x, y
5. Stop z=xx=yy=z

Write x, y

Stop

5 |Page
Q6. Design a program to find the circumference of a circle. Use the formula: C=2πr, where π is approximately equivalent 3.1416.

Algorithm Flowchart Program

1. Start
2. Read r Start
3. Calculate circumference by
the equation:
Circum = 2*pi*r Read r
4. Print Circum
5. Stop
Circum = 2*pi*r

Write Circum

Stop

6 |Page
Q7. Write a program that takes as input the purchase price of an item (P), its expected number of years of service (Y) and its expected salvage value
(S). Then outputs the yearly depreciation for the item (D). Use the formula: D = (P - S) Y

Algorithm Flowchart Program

1. Start
2. Read P Start
3. Read S
4. Read Y
5. D = (P-S) * Y Read P
6. Print or display D
7. Stop

Read S

Read Y

D = (P-S) * Y

Write D

Stop

7 |Page
Q8. Swapping of 2 variables without using temporary (or 3rd variable)

Algorithm Flowchart Program

1. Start
2. Read x and y Start
3. x = x + y
y=x-y
x=x-y Read x, y
4. Print or display x, y
5. Stop
x=x+yy=x-yx=x-y

Write x, y

Stop

8 |Page
Q9. Determine the most economical quantity to be stocked for each product that a manufacturing company has in its inventory: This quantity, called
economic order quantity (EOQ) is calculated as follows: EOQ=2rs/1 where: R= total yearly production requirement S=set up cost per order
I=inventory carrying cost per unit

Algorithm Flowchart Program

1. Start
2. Read R Start
3. Read S
4. Read I
5. EOQ = (2*R*S)/I
Read R
6. Print EOQ
7. Stop

Read S

Read I

EOQ = (2*R*S)/I

Write EOQ

Stop

9 |Page
Q10. Write a program to compute the radius of a circle. Derive your formula from the given equation: A=πr², then display the output.

Algorithm Flowchart Program

1. Start
2. Read r Start
3. Calculate radius by
the equation:
r = sqrt(A/pi) Read A
4. Write r
5. Stop

r = sqrt(A/pi)

Write r

Stop

10 |Page
11 |Page

1 | P a g e
Start
Read r
Write vol
Stop
vol = (4/3) *pi*r*r*r
Solved
 
   Assignment
 
   Problems in
 
   C     (with
 
   A
Start
Read C
Write Fh
Stop
Fh = (1.8*C) + 32
C=0, F=0
2 | P a g e
Q2. Write a program the converts the input Celsius degree i
Start
Read dollar
Write peso
Stop
peso = dollar * 51.50
3 | P a g e
Q3. Write a program that converts the input dollar to its
Start
Read   inch
Write cm
Stop
pcm = 2.54 * inch
4 | P a g e
Q4. Write a program that converts an input inch(es) into its eq
Start
Read   x, y
Write x, y
Stop
z = x x = y y = z
5 | P a g e
Q5. Write a program that exchanges the value of two variables
Start
Read   r
Write Circum
Stop
Circum = 2*pi*r
6 | P a g e
Q6. Design a program to find the circumference of a circle. Use
Start
Read   P
Read   S
Read   Y
Write D
Stop
D = (P-S) * Y
7 | P a g e
Q7. Write a program that takes as input the purchase
Start
Read   x, y
Write x, y
Stop
x = x + y y = x - y x = x - y
8 | P a g e
Q8. Swapping of 2 variables without using tempora
Start
Read   R
Read   S
Read   I
Write EOQ
Stop
EOQ = (2*R*S)/I
9 | P a g e
Q9. Determine the most economical quantity to be
Start
y
Read   A
Write r
Stop
r = sqrt(A/pi)
10 | P a g e
Q10. Write a program to compute the radius of a circle. Derive your

You might also like