Variable, Operator and Expression

[Set – 1]

1. Write a program that asks the user for his name and then welcomes him. The output should look like this:

Enter your name: Saksham
Hello Saksham
Solution

2. Write a program that prompts the user to enter two integers and display their sum on the screen. Solution

3. Write a program that prompts the user to input a Celsius temperature and outputs the equivalent temperature in Fahrenheit. The formula to convert the temperature is: F = 9/5 C + 32 where F is the Fahrenheit temperature and C is the Celsius temperature. Solution

4. Write a program which accept principle, rate and time from user and print the simple interest. The formula to calculate simple interest is: simple interest = principle x rate x time / 100 Solution

5. Write a program that accepts seconds from keyboard as integer. Your program should converts seconds in hours, minutes and seconds. Your output should like this :

Enter seconds: 13400
Hours: 3
Minutes: 43
Seconds: 20  Solution

6. Write a program that prompts the user to enter number in two variables and swap the contents of the variables. Solution

7. Write a program that prompts the user to enter number in two variables and swap the contents of the variables.(Do not declare extra variable.) Solution

8. Write a program that prompts the user to input the radius of a circle and outputs the area and circumference of the circle. The formula is
Area = pi x radius2
Circumference = 2 x pi x radius
Solution

9. Write a program that prompts the user to input the length and the width of a rectangle and outputs the area and perimeter of the rectangle. The formula is
Area = Length x Width
Circumference = 2 x ( Length + Width)
Solution

10. Suppose a, b, and c denote the lengths of the sides of a triangle. Then the area of the triangle can be calculated using the formula:

where
Write a program that asks the user to input the length of sides of the triangle and print the area. Solution

11. Write a program which prompts the user to input principle, rate and time and calculate compound interest. The formula is :
CI = P(1+R/100)^T - P Solution