C Programming First Practical Assignment
C Programming First Practical Assignment
1. write a c program that initializes two variables to 50.8 and 21.2 respectively and displays
their sum.
2. write a c program that initializes a radius of the circle to 6.5 displays the area.
3. write a c program that initializes a radius of the cylinder to 5.5 and the height to 6 and
displays the volume of the cylinder.
GETTING THE INPUT FROM The User using scanf() function
4. Write a c program that asks the user to type his/her age and then displays his/her age.
5. write a c program that asks the user to enter two numbers and displays their product.
6. Write a C program that converts Centigrade to Fahrenheit
Expected Output:
Input a temperature (in Centigrade): 45
113.000000 degrees Fahrenheit.
7. Write a C program that calculates the volume of a sphere.
Expected Output:
Input the radius of the sphere: 2.56
the volume of sphere is 70.276237.
8. Write a C program that takes the height and width as input and prints the perimeter of a
rectangle.
Expected Output :
Input the height of the Rectangle : 5
Input the width of the Rectangle : 7
Perimeter of the Rectangle is : 24.000000
9. Write a C program that converts kilometers per hour to miles per hour
Expected Output:
Input kilometres per hour: 15
9.32057 miles per hour
10. Write a C program that takes hours and minutes as input, and calculates the total number
of minutes.
Expected Output:
Input hours: 6
Input minutes: 40
Total: 400 minutes.
11. Write a program in C that takes minutes as input, and display the total number of hours
and minutes.
Expected Output :
Input minutes: 400
6 Hours, 40 Minutes
12. Write a program in C that reads a firstname, surname and year of birth and display the
names and the year one after another sequentially.
Expected Output :
Input your firstname: Tom
Input your lastname: Davis
Input your year of birth: 1982
Tom Davis 1982
13. Write a program in C that takes input of three numbers separated by a comma, and
calculates their sum.
Expected Output :
Input three numbers separated by comma : 2,5,3
The sum of three numbers : 10
14. Write a program in C that takes input of two numbers from the user, and performs
addition, subtraction, multiplication and division:
Expected Output :
Input any two numbers separated by comma : 5,2
The sum of the given numbers : 7
The difference of the given numbers : 3
The product of the given numbers : 10
The quotient of the given numbers : 2.500000
15. Write a program in C that takes input of two angles of a triangle from the user, and
calculates the third angle:
Expected Output:
Input first angle of the triangle: 80
Input second angle of the triangle: 30
Third angle of the triangle: 70