Practicing and solving problems is essential for learning C programming effectively. These examples help build programming skills and prepare for common C programming problems.
- Includes over 100 C programming examples covering basics, strings, arrays, pointers, conversions, pattern printing, and more.
- Covers problems from fundamental to advanced concepts, including questions frequently asked in C programming interviews.
Basic
These basic C programs help beginners understand fundamental concepts such as input, output, variables, arithmetic operations, and basic calculations.
- Hello World Program
- Print Your Own Name
- Print an Integer Entered By the User
- Add Two Numbers
- Check Whether a Number is Prime or Not
- Multiply two Floating-Point Numbers
- Print the ASCII Value of a Character
- Swap Two Numbers
- Calculate Fahrenheit to Celsius
- Find the Size of int, float, double, and char
- Add Two Complex Numbers
- Print Prime Numbers From 1 to N
- Find Simple Interest
- Find Compound Interest
- Area And Perimeter Of Rectangle
Control Flow
These C programs cover decision-making and looping concepts such as if-else, switch, for, while, and do-while loops.
- Check Whether a Number is Positive, Negative, or Zero
- Check Whether Number is Even or Odd
- Check Whether a Character is Vowel or Consonant
- Find Largest Number Among Three Numbers
- Calculate Sum of Natural Numbers
- Print Alphabets From A to Z Using Loop
- Check Leap Year
- Find Factorial of a Number
- Make a Simple Calculator
- Generate Multiplication Table
- Print Fibonacci Series
- Find LCM of Two Numbers
- Check Armstrong Number
- Display Armstrong Numbers Between 1 to 1000
- Display Armstrong Number Between Two Intervals
- Reverse a Number
- Check Whether a Number is a Palindrome or Not
- Check Whether a Number is Prime or Not
- Display Prime Numbers Between Intervals
- Check whether the input number is a Neon Number
- Find All Factors of a Natural Number
- Sum of Fibonacci Numbers at Even Indexes up to N Terms
Pattern Printing
These C programs demonstrate how to use nested loops to print different star, number, and character patterns.
- Print Simple Pyramid Pattern
- Print Given Triangle
- Print 1800 Rotation of Simple Pyramid
- Print Inverted Pyramid
- Print Number Pattern
- Print Character Pattern
- Print Continuous Character Pattern
- Print Hollow Star Pyramid
- Print Inverted Hollow Star pyramid
- Print Hollow Star Pyramid in a Diamond Shape
- Print Full Diamond Shape Pyramid
- Print Pascal's Pattern Triangle Pyramid
- Print Floyd's Pattern Triangle Pyramid
- Print Reverse Floyd pattern Triangle Pyramid
Functions
These C programs demonstrate how to define and use functions, pass arguments, return values, and apply recursion in C.
- Check Prime Number By Creating a Function
- Display Prime Numbers Between Two Intervals Using Functions
- Find All Roots of a Quadratic Equation
- Check Whether a Number can be Express as Sum of Two Prime Numbers
- Find the Sum of Natural Numbers using Recursion
- Calculate the Factorial of a Number Using Recursion
- Find G.C.D Using Recursion
- Reverse a Stack using Recursion
- Calculate Power Using Recursion
Arrays
These C programs cover common operations on one-dimensional and two-dimensional arrays, including searching, sorting, and matrix operations.
- Print a 2D Array
- Find the Largest Element in an Array
- Find the Maximum and Minimum in an Array
- Search an Element in an Array (Binary search)
- Calculate the Average of All the Elements Present in an Array
- Sort an Array using Bubble Sort
- Sort an Array using Merge Sort
- Sort an Array Using Selection Sort
- Sort an Array Using Insertion Sort
- Sort the Elements of an Array in Descending Order
- Sort the Elements of an Array in Ascending Order
- Remove Duplicate Elements From a Sorted Array
- Merge Two Arrays
- Remove All Occurrences of an Element in an Array
- Find Common Array Elements
- Copy All the Elements of One Array to Another Array
- Array Rotation
- Sort the 2D Array Across Rows
- Check Whether Two Matrices Are Equal or Not
- Find the Transpose
- Find the Determinant of a Matrix
- Find the Normal and Trace
- Add Two Matrices
- Multiply Two Matrices
- Print Boundary Elements of a Matrix
- Rotate Matrix Elements
- Compute the Sum of Diagonals of a Matrix
- Interchange Elements of First and Last in a Matrix Across Rows
- Interchange Elements of First and Last in a Matrix Across Columns
Strings
These C programs demonstrate common string operations such as concatenation, comparison, reversal, searching, and manipulation.
- Add or Concatenate Two Strings
- Add 2 Binary Strings
- Get a Non-Repeating Character From the Given String
- check if the string is palindrome or not
- Reverse an Array or String
- Reverse a String Using Recursion
- Find the Length of a String
- Sort a String
- Check For Pangram String
- Print the First Letter of Each Word
- Determine the Unicode Code Point at a Given Index
- Remove Leading Zeros
- Compare Two Strings
- Compare Two Strings Lexicographically
- Insert a String into Another String
- Split a String into a Number of Sub-Strings
Conversions
These C programs cover conversions between different data types and number systems, such as binary, decimal, octal, hexadecimal, and strings.
- Boolean to String Conversion
- Float to String Conversion
- Double to String Conversion
- String to Long Conversion
- Long to String Conversion
- Int to Char Conversion
- Char to Int Conversion
- Octal to Decimal Conversion
- Decimal to Octal Conversion
- Hexadecimal to Decimal Conversion
- Decimal to Hexadecimal Conversion
- Decimal to Binary Conversion
- Binary to Decimal Conversion
Pointers
These C programs demonstrate the use of pointers for accessing, modifying, and manipulating data stored in memory.
- How to Return a Pointer from a Function in C
- How to Declare a Two-Dimensional Array of Pointers in C?
- Find the Largest Element in an Array using Pointers
- Swap Two Numbers
- Sort an Array using Pointers
- Sort a 2D Array of Strings
- Check if a String is a Palindrome using Pointers
- Create a Copy of a Singly Linked List using Recursion
Structures and Unions
These C programs demonstrate how structures and unions can be used to group and manage different types of related data.
- Store Information of Students Using Structure
- Store Student Records as Structures and Sort them by Name
- Add N Distances Given in inch-feet System using Structures
- Add Two Complex Numbers by Passing Structure to a Function
- Store Student Records as Structures and Sort them by Age or ID
- Read/Write Structure to a File in C
- Flexible Array Members in a Structure in C
File IO
These C programs cover file handling operations such as creating, reading, writing, copying, renaming, and comparing files.
- Create a Temporary File
- Read/Write Structure to a File
- Rename a file
- Make a File Read-Only
- Compare Two Files and Report Mismatches
- Copy One File into Another File
- Print all the Patterns that Match Given Pattern From a File
- Append the Content of One Text File to Another
- Read Content From One File and Write it Into Another File
- Read and Print all Files From a Zip File
Date and Time
These C programs demonstrate how to work with dates and times, including formatting, conversion, and displaying the current date and time.
- Format time in AM-PM format
- Print Digital Clock with the Current Time
- Display Dates of Calendar Year in Different Formats
- Display Current Date and Time
- Maximize Time by Replacing ‘_’ in a Given 24-Hour Format Time
- Convert the Local Time to GMT
- Convert Hours into Minutes and Seconds
More C Programs
This section contains additional C programs covering errors, mathematical operations, graphics, source code manipulation, and other useful programming problems.