- C Data Types
- C Operators
- C Input and Output
- C Control Flow
- C Functions
- C Preprocessors
- C File Handling
- C Cheatsheet
- C Interview Questions
C Exercises - Practice Questions with Solutions for C Programming
The best way to learn C programming language is by hands-on practice. This C Exercise page contains the top 30 C exercise questions with solutions that are designed for both beginners and advanced programmers. It covers all major concepts like arrays, pointers, for-loop, and many more.
So, Keep it Up! Solve topic-wise C exercise questions to strengthen your weak topics.
Also, Once you've covered basic C exercises, the GeeksforGeeks Practice Platform is a great place to take on more advanced C coding problems and improve your understanding.
C Programming Exercises
The following are the top 30 programming exercises with solutions to help you practice online and improve your coding efficiency in the C language. You can solve these questions online in GeeksforGeeks IDE.
Q1: Write a Program to Print "Hello World!" on the Console.
In this problem, you have to write a simple program that prints "Hello World!" on the console screen.
For Example,
Click here to view the solution.
Q2: write a program to find the sum of two numbers entered by the user..
In this problem, you have to write a program that adds two numbers and prints their sum on the console screen.
Q3: Write a Program to find the size of int, float, double, and char.
In this problem, you have to write a program to print the size of the variable.
Q4: Write a Program to Swap the values of two variables.
In this problem, you have to write a program that swaps the values of two variables that are entered by the user.
Q5: Write a Program to calculate Compound Interest.
In this problem, you have to write a program that takes principal, time, and rate as user input and calculates the compound interest.
Q6: Write a Program to check if the given number is Even or Odd.
In this problem, you have to write a program to check whether the given number is even or odd.
Q7: Write a Program to find the largest number among three numbers.
In this problem, you have to write a program to take three numbers from the user as input and print the largest number among them.
Q8: Write a Program to make a simple calculator.
In this problem, you have to write a program to make a simple calculator that accepts two operands and an operator to perform the calculation and prints the result.
Q9: Write a Program to find the factorial of a given number.
In this problem, you have to write a program to calculate the factorial (product of all the natural numbers less than or equal to the given number n) of a number entered by the user.
Q10: Write a Program to Convert Binary to Decimal.
In this problem, you have to write a program to convert the given binary number entered by the user into an equivalent decimal number.
Q11: Write a Program to print the Fibonacci series using recursion.
In this problem, you have to write a program to print the Fibonacci series(the sequence where each number is the sum of the previous two numbers of the sequence) till the number entered by the user using recursion.
Q12: Write a Program to Calculate the Sum of Natural Numbers using recursion.
In this problem, you have to write a program to calculate the sum of natural numbers up to a given number n.
Q13: Write a Program to find the maximum and minimum of an Array.
In this problem, you have to write a program to find the maximum and the minimum element of the array of size N given by the user.
Q14: Write a Program to Reverse an Array.
In this problem, you have to write a program to reverse an array of size n entered by the user. Reversing an array means changing the order of elements so that the first element becomes the last element and the second element becomes the second last element and so on.
Q15: Write a Program to rotate the array to the left.
In this problem, you have to write a program that takes an array arr[] of size N from the user and rotates the array to the left (counter-clockwise direction) by D steps, where D is a positive integer.
Q16: Write a Program to remove duplicates from the Sorted array.
In this problem, you have to write a program that takes a sorted array arr[] of size N from the user and removes the duplicate elements from the array.
Q17: Write a Program to search elements in an array (using Binary Search).
In this problem, you have to write a program that takes an array arr[] of size N and a target value to be searched by the user. Search the target value using binary search if the target value is found print its index else print 'element is not present in array '.
Q18: Write a Program to reverse a linked list.
In this problem, you have to write a program that takes a pointer to the head node of a linked list, you have to reverse the linked list and print the reversed linked list.
Q18: Write a Program to create a dynamic array in C.
In this problem, you have to write a program to create an array of size n dynamically then take n elements of an array one by one by the user. Print the array elements.
Q19: Write a Program to find the Transpose of a Matrix.
In this problem, you have to write a program to find the transpose of a matrix for a given matrix A with dimensions m x n and print the transposed matrix. The transpose of a matrix is formed by interchanging its rows with columns.
Q20: Write a Program to concatenate two strings.
In this problem, you have to write a program to read two strings str1 and str2 entered by the user and concatenate these two strings. Print the concatenated string.
Q21: Write a Program to check if the given string is a palindrome string or not.
In this problem, you have to write a program to read a string str entered by the user and check whether the string is palindrome or not. If the str is palindrome print 'str is a palindrome' else print 'str is not a palindrome'. A string is said to be palindrome if the reverse of the string is the same as the string.
Q22: Write a program to print the first letter of each word.
In this problem, you have to write a simple program to read a string str entered by the user and print the first letter of each word in a string.
Q23: Write a program to reverse a string using recursion
In this problem, you have to write a program to read a string str entered by the user, and reverse that string means changing the order of characters in the string so that the last character becomes the first character of the string using recursion.
Q24: Write a program to Print Half half-pyramid pattern.
In this problem, you have to write a simple program to read the number of rows (n) entered by the user and print the half-pyramid pattern of numbers. Half pyramid pattern looks like a right-angle triangle of numbers having a hypotenuse on the right side.
Q25: Write a program to print Pascal’s triangle pattern.
In this problem, you have to write a simple program to read the number of rows (n) entered by the user and print Pascal’s triangle pattern. Pascal’s Triangle is a pattern in which the first row has a single number 1 all rows begin and end with the number 1. The numbers in between are obtained by adding the two numbers directly above them in the previous row.
Q26: Write a program to sort an array using Insertion Sort.
In this problem, you have to write a program that takes an array arr[] of size N from the user and sorts the array elements in ascending or descending order using insertion sort.
Q27: Write a program to sort an array using Quick Sort.
In this problem, you have to write a program that takes an array arr[] of size N from the user and sorts the array elements in ascending order using quick sort.
Q28: Write a program to sort an array of strings.
In this problem, you have to write a program that reads an array of strings in which all characters are of the same case entered by the user and sort them alphabetically.
Q29: Write a program to copy the contents of one file to another file.
In this problem, you have to write a program that takes user input to enter the filenames for reading and writing. Read the contents of one file and copy the content to another file. If the file specified for reading does not exist or cannot be opened, display an error message "Cannot open file: file_name" and terminate the program else print "Content copied to file_name"
Q30: Write a program to store information on students using structure.
In this problem, you have to write a program that stores information about students using structure. The program should create various structures, each representing a student's record. Initialize the records with sample data having data members' Names, Roll Numbers, Ages, and Total Marks. Print the information for each student.
We hope after completing these C exercises you have gained a better understanding of C concepts. Learning C language is made easier with this exercise sheet as it helps you practice all major C concepts. Solving these C exercise questions will take you a step closer to becoming a C programmer.
Frequently Asked Questions (FAQs)
Q1. what are some common mistakes to avoid while doing c programming exercises.
Some of the most common mistakes made by beginners doing C programming exercises can include missing semicolons, bad logic loops, uninitialized pointers, and forgotten memory frees etc.
Q2. What are the best practices for beginners starting with C programming exercises?
Best practices for beginners starting with C programming exercises: Start with easy codes Practice consistently Be creative Think before you code Learn from mistakes Repeat!
Q3. How do I debug common errors in C programming exercises?
You can use the following methods to debug a code in C programming exercises Read the error message carefully Read code line by line Try isolating the error code Look for Missing elements, loops, pointers, etc Check error online
Similar Reads
Please login to comment..., improve your coding skills with practice.
What kind of Experience do you want to share?
C Functions
C structures, c reference, c exercises.
You can test your C skills with W3Schools' Exercises.
We have gathered a variety of C exercises (with answers) for each C Chapter.
Try to solve an exercise by editing some code, or show the answer to see what you've done wrong.
Count Your Score
You will get 1 point for each correct answer. Your score and total score will always be displayed.
Start C Exercises
Start C Exercises ❯
If you don't know C, we suggest that you read our C Tutorial from scratch.
COLOR PICKER
Contact Sales
If you want to use W3Schools services as an educational institution, team or enterprise, send us an e-mail: [email protected]
Report Error
If you want to report an error, or if you want to make a suggestion, send us an e-mail: [email protected]
Top Tutorials
Top references, top examples, get certified.
- Data Structure
- Coding Problems
- C Interview Programs
- C++ Aptitude
- Java Aptitude
- C# Aptitude
- PHP Aptitude
- Linux Aptitude
- DBMS Aptitude
- Networking Aptitude
- AI Aptitude
- MIS Executive
- Web Technologie MCQs
- CS Subjects MCQs
- Databases MCQs
- Programming MCQs
- Testing Software MCQs
- Digital Mktg Subjects MCQs
- Cloud Computing S/W MCQs
- Engineering Subjects MCQs
- Commerce MCQs
- More MCQs...
- Machine Learning/AI
- Operating System
- Computer Network
- Software Engineering
- Discrete Mathematics
- Digital Electronics
- Data Mining
- Embedded Systems
- Cryptography
- CS Fundamental
- More Tutorials...
- Tech Articles
- Code Examples
- Programmer's Calculator
- XML Sitemap Generator
- Tools & Generators
Home » C programming language
C Programs with Solutions
This section contains popular C programs with solution. Learn and practice these programs to test and enhance your C skills. Last updated : April 01, 2023
The best way to learn C programming is by practicing and solving the C programs (C problems). We have 1000+ C programs with solutions which are categorized below. Practice these C programs to learn and enhance your C problem-solving skills.
List of C programs
Practice the C programs based on the categories, library functions, advanced, top searched, and latest.
C programs by categories
- C Basic and Conditional Programs 90
- C switch case programs 06
- C 'goto' programs 10
- Bitwise related Programs 32
- Looping (for, while, do while) Programs 18
- C String Manipulation programs 10
- C String programs 50
- String User Define Functions Programs 11
- Recursion Programs 13
- Number (Digits Manipulation) Programs 10
- Number System Conversion Programs 15
- Star/Pyramid Programs 17
- Sum of Series Programs (set 1) 05
- Sum of Series Programs (set 2) 13
- Pattern printing programs 01
- User Define Function Programs (1) 05
- User Define Function Programs (2) 13
- One Dimensional Array Programs 58
- Two Dimensional Array (Matrix) Programs 21
- File Handling Programs 32
- Structure & Union Programs 12
- Pointer Programs 13
- Dynamic Memory Allocation Programs 05
- Command Line Arguments Programs 06
- Common C program Errors 22
- C scanf() programs 11
- C preprocessor programs 24
- C typedef programs 03
- C SQLite programs 11
- C MySQL programs 09
- C Tricky Programs 07
- Misc Problems & Solutions 05
C programs on standard library functions
- ctype.h Library Functions (Set 1)
- ctype.h Library Functions (Set 2)
- string.h Library Functions
- conio.h Library Functions
- dos.h Library Functions
- math.h Library Functions
- graphics.h Library Functions
- assert.h Library Functions
- stdio.h Library Functions
Advance C programs
- C program to create your own header file/ Create your your own header file in C
- gotoxy(),clrscr(),getch(),getche() for GCC, Linux.
- fork() function explanation and examples in Linux C
- C program to print character without using format specifiers.
- C program to find Binary Addition and Binary Subtraction.
- C program to print weekday of given date.
- C program to format/extract ip address octets
- C program to check given string is a valid IPv4 address or not.
- C program to extract bytes from an integer (Hexadecimal) value
- C program to store date in an integer variable
Top searched C programs
Here is the list of most important/useful programs searched on the web .
Top visited programs on IncludeHelp
- Pattern Programs in C
- C program to design calculator with basic operations using switch
- C program to find factorial of a number
- C program to check whether number is Perfect Square or not
- C program to find SUM and AVERAGE of two numbers
- C program to convert temperature from Fahrenheit to Celsius and Celsius to Fahrenheit
- C program to read and print an employee's detail using structure
- Dynamic Memory Allocation programs
- C program to convert number from Decimal to Binary
- C program to check whether number is Palindrome or not
Top searched programs on the web
- First C program to print "Hello World".
- C program to find factorial of a number.
- C program to swap two numbers without using third variable.
- C program to check whether a number if Armstrong or not.
- C program to check whether a number if Even or Odd.
- C program to print all leap years from 1 to N.
- C program to calculate employee gross salary.
- C Program to print tables of numbers from 1 to 20.
- C program to print star/pyramid series.
- C program to convert temperature from Celsius to Fahrenheit and vice versa.
- C program to convert number from Decimal to Binary.
- C program to convert number from Binary to Decimal.
- C program to print ASCII Table.
- C program to get and set current system date and time.
- C program to run dos command.
Latest C programs
- C program to generate random numbers within a range
- C program to compare strings using strcmp() function
- Interchange the two adjacent nodes in a given circular linked list | C program
- Find the largest element in a doubly linked list | C program
- Convert a given singly linked list to a circular list | C program
- Implement Circular Doubly Linked List | C program
- Print the Alternate Nodes in a Linked List without using Recursion
- Print the Alternate Nodes in a Linked List using Recursion
- Find the length of a linked list without using recursion
- Find the length of a linked list using recursion
- Count the number of occurrences of an element in a linked list without using recursion
- Count the number of occurrences of an element in a linked list using recursion
- C program to convert a Binary Tree into a Singly Linked List by Traversing Level by Level
- C program to Check if nth Bit in a 32-bit Integer is set or not
- C program to swap two Integers using Bitwise Operators
- C program to replace bit in an integer at a specified position from another integer
- C program to find odd or even number using bitmasking
- C program to check whether a given number is palindrome or not using Bitwise Operator
- C program to count number of bits set to 1 in an Integer
- C program to check if all the bits of a given integer is one (1)
- C program to find the Highest Bit Set for any given Integer
- C program to Count the Number of Trailing Zeroes in an Integer
- C Program to find the Biggest Number in an Array of Numbers using Recursion
- C program to accept Sorted Array and do Search using Binary Search
- C Program to Cyclically Permute the Elements of an Array
- C program to find two smallest elements in a one dimensional array
- Write your own memset() function in C
- memset() function in C with Example
- Write your own memcpy() function in C
- memcpy() function in C with Example
Comments and Discussions!
Load comments ↻
- Marketing MCQs
- Blockchain MCQs
- Artificial Intelligence MCQs
- Data Analytics & Visualization MCQs
- Python MCQs
- C++ Programs
- Python Programs
- Java Programs
- D.S. Programs
- Golang Programs
- C# Programs
- JavaScript Examples
- jQuery Examples
- CSS Examples
- C++ Tutorial
- Python Tutorial
- ML/AI Tutorial
- MIS Tutorial
- Software Engineering Tutorial
- Scala Tutorial
- Privacy policy
- Certificates
- Content Writers of the Month
Copyright © 2024 www.includehelp.com. All rights reserved.
Snapsolve any problem by taking a picture. Try it in the Numerade app?
"Hello World!" in C Easy C (Basic) Max Score: 5 Success Rate: 85.54%
Playing with characters easy c (basic) max score: 5 success rate: 84.34%, sum and difference of two numbers easy c (basic) max score: 5 success rate: 94.58%, functions in c easy c (basic) max score: 10 success rate: 96.02%, pointers in c easy c (basic) max score: 10 success rate: 96.61%, conditional statements in c easy c (basic) max score: 10 success rate: 96.89%, for loop in c easy c (basic) max score: 10 success rate: 93.78%, sum of digits of a five digit number easy c (basic) max score: 15 success rate: 98.65%, bitwise operators easy c (basic) max score: 15 success rate: 94.98%, printing pattern using loops medium c (basic) max score: 30 success rate: 95.94%, cookie support is required to access hackerrank.
Seems like cookies are disabled on this browser, please enable them to open this website
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
- Write a C program to perform input/output of all basic data types .
- Write a C program to enter two numbers and find their sum.
- Write a C program to enter two numbers and perform all arithmetic operations.
- Write a C program to enter length and breadth of a rectangle and find its perimeter.
- Write a C program to enter length and breadth of a rectangle and find its area.
- Write a C program to enter radius of a circle and find its diameter, circumference and area.
- Write a C program to enter length in centimeter and convert it into meter and kilometer.
- Write a C program to enter temperature in Celsius and convert it into Fahrenheit.
- Write a C program to enter temperature in Fahrenheit and convert to Celsius
- Write a C program to convert days into years, weeks and days .
- Write a C program to find power of any number x ^ y.
- Write a C program to enter any number and calculate its square root.
- Write a C program to enter two angles of a triangle and find the third angle.
- Write a C program to enter base and height of a triangle and find its area.
- Write a C program to calculate area of an equilateral triangle.
- Write a C program to enter marks of five subjects and calculate total, average and percentage.
- Write a C program to enter P, T, R and calculate Simple Interest.
- Write a C program to enter P, T, R and calculate Compound Interest.
IMAGES
VIDEO
COMMENTS
This C Exercise page contains the top 30 C exercise questions with solutions that are designed for both beginners and advanced programmers. It covers all major concepts like arrays, pointers, for-loop, and many more.
Our resource for Problem Solving with C++ includes answers to chapter exercises, as well as detailed information to walk you through the process step by step. With Expert Solutions for thousands of practice problems, you can take the guesswork out of studying and move forward with confidence.
Fundamentals. Hello world program in C. Basic input/output. Basic IO on all data types. Perform arithmetic operations. Find area and perimeter of rectangle. Find diameter and area of circle. Find area of triangle. Find angles of triangle.
We have gathered a variety of C exercises (with answers) for each C Chapter. Try to solve an exercise by editing some code, or show the answer to see what you've done wrong.
C programming Exercises, Practice, Solution: C is a general-purpose, imperative computer programming language, supporting structured programming, lexical variable scope and recursion, while a static type system prevents many unintended operations.
The best way to learn C programming is by practicing and solving the C programs (C problems). We have 1000+ C programs with solutions which are categorized below. Practice these C programs to learn and enhance your C problem-solving skills.
Improve your C programming skills with over 200 coding practice problems. Solve these beginner friendly problems online to get better at C language.
Step-by-step video answers explanations by expert educators for all Problem Solving with C++ 10th by Walter J. Savitch only on Numerade.com.
Join over 23 million developers in solving code challenges on HackerRank, one of the best ways to prepare for programming interviews.
List of basic programming exercises. Write a C program to perform input/output of all basic data types. Write a C program to enter two numbers and find their sum. Write a C program to enter two numbers and perform all arithmetic operations.