Problem Statements for Structure and Functions



Statements 

1. Write a program to calculate and print the area of a rectangle given height and width. Height = 5, Width = 4.

2. Write a program to calculate the simple interest. It inputs the principal amount, rate of interest, and the number of years and displays simple interest.

Hint: Interest = Principal amount * Rate of Interest * No of Years/100

3. Write a program that inputs a character and displays its ASCII code.

4. Write a program that inputs Dividend and Divisor. It then calculates and displays the Quotient and Reminder. 

See Example:

Dividend = 5, Divisor = 2.

= 5/2

Quotient is 2 and Reminder is 1.

 5. Write a program that inputs two numbers, swaps the values, and then displays them. For example, x = 5 and y = 10. After swap the value of x = 10 and y = 5.

Hint: Create a third variable.

6. Write a program that inputs two numbers, swaps these values without using a third variable, and displays them.

Hint: Using arithmetic operation.

7. Write a program that inputs based and height from the user. It calculates and displays the area of a triangle by using the formula Area = ½ * Base * Height.

8. Write a program that inputs the distance traveled and speed of the vehicle. It calculates the time required to reach the destination and displays it.

9. Write a program that gets the temperature from the user in Celsius and converts it into Fahrenheit and Kelvin.

Hint: Fahrenheit = 9/5 * Celsius + 32

Kelvin                 = Celsius + 273.15

10.  Write a program that inputs a five-digit number from the user and displays it in reverse order. 

For example, if the user enters 12345, it displays 54321.

11. Write a program that will prompt the user to enter for a number of hours. It computes and displays the number of weeks, days, and hours within the input number of hours.

See Example, if the user enters the number of hours 200 display the result like

Week = 1

Days = 1

Hour = 8

12. Write a program to print the following messages:

             C

O       M

                   P       U       T

                   E       R       I        S

                   A       W      O       R       L

                   D       O       F       S

                   C       I        E

                   N       C

                   E

 

Post a Comment

0 Comments