0% found this document useful (0 votes)
4 views

Practice Algo

Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views

Practice Algo

Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

I. Write the algorithms for the following.

1. Write a program to calculate the taxi fare from airport to hotel. The basic charge to take a taxi is $2
and the additional fee is calculated based on distance in kilometer - $3 for 1 kilometer. The total taxi
fare is the total of basic charge and charge based on distance. The distance in kilometer must be
accepted as input.

2. Write a program to calculate the length of a side in triangle. The perimeter of triangle is the sum of
three sides (P=a+b+c). The program needs to calculate the length of third side, c. The perimeter and
the length of sides “a” and “b” are accepted from the user.
3. Accept Celsius degree from the user and change it to relative Fahrenheit degree.
F= (9/5) * C+32
4. Accept Fahrenheit degree and change it to relative Celsius degree.
C=(F-32) *5/9
5. Accept radius of a circle from the user. Compute diameter and area of triangle.
area = 3.14*r*r, diameter=r+r

6. Write a program to find the area of triangle. Ask the user to enter base and height of the
triangle. The basic formula for the area of a triangle is equal to half the product of its base and height
i.e., Area=0.5 * base * height.
7. Write an algorithm to find the perimeter of triangle.
perimeter of triangle = a+b+c, where a, b and c are sides of the triangle. The values of a, b and c are
4,4,6 respectively.

8. Write a program to find the total of all subjects of a student. The student will input the marks
of three subjects and the program accepts these inputs and produce the total output to the students.

9.Write an algorithm to find the entrance fee to the museum. The entrance fee is calculated based on
the guest’ age. If the age of a guest is greater than (>) 10, then the fee must be $20. If not, then the fee
must be $10. Compute the fee and reply to the guest.

1
2

You might also like