w3resource

C Programming Exercises, Practice, Solution : Input Output


This resource offers a total of 50 C Basic Input Output statement problems for practice. It includes 10 main exercises, each accompanied by solutions, detailed explanations, and four related problems.

[An Editor is available at the bottom of the page to write and execute the scripts.]


1. Centigrade to Fahrenheit Conversion

Write a program that converts Centigrade to Fahrenheit.
Expected Output :
Input a temperature (in Centigrade): 45
113.000000 degrees Fahrenheit.

Click me to see the solution


2. Volume of a Sphere Calculation

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.

Click me to see the solution


3. Rectangle Perimeter Calculation

Write a C program that prints the perimeter of a rectangle using its height and width as inputs.
Expected Output :
Input the height of the Rectangle : 5
Input the width of the Rectangle : 7
Perimeter of the Rectangle is : 24.000000

Click me to see the solution


4. Kilometers per Hour to Miles per Hour Conversion

Write a C program that converts kilometers per hour to miles per hour.
Expected Output :
Input kilometers per hour: 15
9.320568 miles per hour

Click me to see the solution


5. Total Minutes Calculation

Write a C program that takes hours and minutes as input, and calculates the total number of minutes.
Expected Output :
Input hours: 5
Input minutes: 37
Total: 337 minutes.

Click me to see the solution


6. Convert Minutes to Hours and Minutes

Write a program in C that takes minutes as input, and display the total number of hours and minutes.
Expected Output :
Input minutes: 546
9 Hours, 6 Minutes

Click me to see the solution


7. Display Personal Information

Write a program in C that reads a forename, surname and year of birth and displays 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

Click me to see the solution


8. Sum of Three Numbers

Write a program in C to calculate the sum of three numbers with input on one line separated by a comma.
Expected Output :
Input three numbers separated by comma : 5,10,15
The sum of three numbers : 30

Click me to see the solution


9. Basic Arithmetic Operations

Write a C program to perform addition, subtraction, multiplication and division of two numbers.
Expected Output :
Input any two numbers separated by comma : 10,5
The sum of the given numbers : 15
The difference of the given numbers : 5
The product of the given numbers : 50
The quotient of the given numbers : 2.000000

Click me to see the solution


10. Triangle Third Angle Calculation

Write a C program to find the third angle of a triangle if two angles are given.
Expected Output :
Input two angles of triangle separated by comma : 50,70
Third angle of the triangle : 60

Click me to see the solution

C Programming Code Editor:



More to Come !

Do not submit any solution of the above exercises at here, if you want to contribute go to the appropriate exercise page.



Follow us on Facebook and Twitter for latest update.