Basic C Exercises

Basic programming exercises and solutions in C

C programming is a stepping stone for many programmers in the programming world. C is best to learn internals of programming and know how a computer program works internally.

Since it is close to low level programming. Programming in C can be a nightmare for beginners if not practiced properly. However, you can learn and practice at Codeforwin step by step.

In this programming exercise we will focus on basics of C programming. After completing this exercise you will learn basic structure and semantics of a C program and how to write mathematical programs in C.

If you are not a beginner, still reached here. Hold your breath I am sure you will find these exercises interesting.

Always feel free to drop your questions in comments section. I love to hear hugs and bugs from you all.

Required knowledge

Operators, Data types, Variables and expression, Basic input/output

List of basic programming exercises 1


  1. C program to print Welcome to c programming
  2. C program to print integer value
  3. C program to print Float value
  4. C program to print Double value
  5. C program to print character
  6. C Program to Print an Integer (Entered by the User)
  7. C Program to Print an Float (Entered by the User)
  8. C Program to Print an Double (Entered by the User)
  9. C Program to Print an Character (Entered by the User)
  10. C Program to Print Two Integers (Entered by the User)
  11. C Program to Print one Integers and one float (Entered by the User)
  12. C Program to Print Data type sizes
  13. C Program to Print variable address
  14. C Program to convert character to ASCII value
  15. C Program to convert ASCII value to character
  16. C Program to swap two numbers with using third variable
  17. C Program to swap two numbers without using third variable
  18. C Program to calculate sum of two numbers
  19. C Program to calculate subtraction of two numbers
  20. C Program to calculate multiplication of two numbers
  21. C Program to calculate division of two numbers
  22. C Program to calculate Remainder of two numbers

List of basic programming exercises 2


  1. Write a C program to perform input/output of all basic data types.

  2. Write a C program to enter two numbers and find their sum.

  3. Write a C program to enter two numbers and perform all arithmetic operations.

  4. Write a C program to enter length and breadth of a rectangle and find its perimeter.

  5. Write a C program to enter length and breadth of a rectangle and find its area.

  6. Write a C program to enter radius of a circle and find its diameter, circumference and area.

  7. Write a C program to enter length in centimeter and convert it into meter and kilometer.

  8. Write a C program to enter temperature in Celsius and convert it into Fahrenheit.

  9. Write a C program to enter temperature in Fahrenheit and convert to Celsius.

  10. Write a C program to convert days into years, weeks and days.

  11. Write a C program to find power of any number x ^ y.

  12. Write a C program to enter any number and calculate its square root.

  13. Write a C program to enter two angles of a triangle and find the third angle.

  14. Write a C program to enter base and height of a triangle and find its area.

  15. Write a C program to calculate area of an equilateral triangle.

  16. Write a C program to enter marks of five subjects and calculate total, average and percentage.

  17. Write a C program to enter P, T, R and calculate Simple Interest.

  18. Write a C program to enter P, T, R and calculate Compound Interest.




Instagram