w3resource logo


C Programming Exercises

C Programming Exercises, Practice, Solution : Input Output

Secondary Nav

C Basic Input Output statement [10 exercises with solution]

1. Write a program that converts Centigrade to Fahrenheit. Go to the editor
Expected Output :
Input a temperature (in Centigrade): 45
113.000000 degrees Fahrenheit.
Click me to see the solution

2. Write a C program that calculates the volume of a sphere. Go to the editor
Expected Output :
Input the radius of the sphere : 2.56
The volume of sphere is 70.276237.
Click me to see the solution

3. Write a C program that prints the perimeter of a rectangle to take its height and width as input. Go to the editor
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. Write a C program that converts kilometers per hour to miles per hour. Go to the editor
Expected Output :
Input kilometers per hour: 15
9.320568 miles per hour
Click me to see the solution

5. Write a C program that takes hours and minutes as input, and calculates the total number of minutes. Go to the editor
Expected Output :
Input hours: 5
Input minutes: 37
Total: 337 minutes.
Click me to see the solution

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

7. Write a program in C that reads a forename, surname and year of birth and display the names and the year one after another sequentially. Go to the editor
Expected Output :
Input your firstname: Tom
Input your lastname: Davis
Input your year of birth: 1988
Tom Davis 1988
Click me to see the solution

8. Write a program in C to calculate the sum of three numbers with getting input in one line separated by a comma. Go to the editor
Expected Output :
Input three numbers separated by comma : 5,10,15
The sum of three numbers : 30
Click me to see the solution

9. Write a C program to perform addition, subtraction, multiplication and  division of two numbers. Go to the editor
Expected Output :
Input any two numbers separated by comma : 15,5
The sum of the given numbers : 20
The difference of the given numbers : 10
The product of the given numbers : 75
The quotient of the given numbers : 3.000000
Click me to see the solution

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

Practice online

#include <stdio.h> 
 int main()  
  {

  }

List of Exercises with Solutions :



Join our Question Answer community to learn and share your programming knowledge.

Help the community:

Python: Fizzbuzz

C++: Decimal to binary conversion

JavaScript: Need Help in JavaScript

Python: Help me with this program