Skip to content
geeksforgeeks
  • Courses
    • DSA to Development
    • Get IBM Certification
    • Newly Launched!
      • Master Django Framework
      • Become AWS Certified
    • For Working Professionals
      • Interview 101: DSA & System Design
      • Data Science Training Program
      • JAVA Backend Development (Live)
      • DevOps Engineering (LIVE)
      • Data Structures & Algorithms in Python
    • For Students
      • Placement Preparation Course
      • Data Science (Live)
      • Data Structure & Algorithm-Self Paced (C++/JAVA)
      • Master Competitive Programming (Live)
      • Full Stack Development with React & Node JS (Live)
    • Full Stack Development
    • Data Science Program
    • All Courses
  • Tutorials
    • Data Structures & Algorithms
    • ML & Data Science
    • Interview Corner
    • Programming Languages
    • Web Development
    • CS Subjects
    • DevOps And Linux
    • School Learning
  • Practice
    • Build your AI Agent
    • GfG 160
    • Problem of the Day
    • Practice Coding Problems
    • GfG SDE Sheet
  • Contests
    • Accenture Hackathon (Ending Soon!)
    • GfG Weekly [Rated Contest]
    • Job-A-Thon Hiring Challenge
    • All Contests and Events
  • C
  • C Basics
  • C Data Types
  • C Operators
  • C Input and Output
  • C Control Flow
  • C Functions
  • C Arrays
  • C Strings
  • C Pointers
  • C Preprocessors
  • C File Handling
  • C Programs
  • C Cheatsheet
  • C Interview Questions
  • C MCQ
  • C++
Open In App
Next Article:
C Multiple Choice Questions
Next article icon

C Programs

Last Updated : 10 Jan, 2025
Comments
Improve
Suggest changes
Like Article
Like
Report

To learn anything effectively, practicing and solving problems is essential. To help you master C programming, we have compiled over 100 C programming examples across various categories, including basic C programs, Fibonacci series, strings, arrays, base conversions, pattern printing, pointers, and more. These C Examples cover a range of questions, from fundamental concepts to advanced topics, and are frequently asked in C-based programming interviews.

C Programs

C Program Topics:

  • Basic C Program
  • Control Flow
  • Pattern Printing
  • Functions
  • Arrays
  • Strings
  • Conversions
  • Pointers
  • Structures and Unions
  • File IO
  • Date and Time
  • More C Programs

Prerequisite: Before you start with these C programs, take a look at our C tutorial to get a good understanding of the basics. Bascally, C programming is a versatile language that powers many foundational systems.

C Program – Basic

  1. C Hello World Program
  2. C Program to Print Your Own Name 
  3. C Program to Print an Integer Entered By the User
  4. C Program to Add Two Numbers
  5. C Program to Check Whether a Number is Prime or Not
  6. C Program to Multiply two Floating-Point Numbers 
  7. C Program to Print the ASCII Value of a Character
  8. C Program to Swap Two Numbers
  9. C Program to Calculate Fahrenheit to Celsius
  10. C Program to Find the Size of int, float, double, and char
  11. C Program to Add Two Complex Numbers 
  12. C Program to Print Prime Numbers From 1 to N 
  13. C Program to Find Simple Interest
  14. C Program to Find Compound Interest
  15. C Program for Area And Perimeter Of Rectangle 

C Program – Control Flow

  1. C Program to Check Whether a Number is Positive, Negative, or Zero
  2. C Program to Check Whether Number is Even or Odd
  3. C Program to Check Whether a Character is Vowel or Consonant 
  4. C Program to Find Largest Number Among Three Numbers
  5. C Program to Calculate Sum of Natural Numbers 
  6. C Program to Print Alphabets From A to Z Using Loop
  7. C Program to Check Leap Year
  8. C Program to Find Factorial of a Number
  9. C Program to Make a Simple Calculator 
  10. C Program to Generate Multiplication Table 
  11. C Program to Print Fibonacci Series
  12. C Program to Find LCM of Two Numbers
  13. C Program to Check Armstrong Number
  14. C Program to Display Armstrong Numbers Between 1 to 1000 
  15. C Program to Display Armstrong Number Between Two Intervals 
  16. C Program to Reverse a Number
  17. C Program to Check Whether a Number is a Palindrome or Not 
  18. C Program to Check Whether a Number is Prime or Not
  19. C Program to Display Prime Numbers Between Intervals
  20. C Program to Check whether the input number is a Neon Number
  21. C Program to Find All Factors of a Natural Number
  22. C program to  Sum of Fibonacci Numbers at Even Indexes up to N Terms 

C Program – Pattern Printing

  1. C Program to Print Simple Pyramid Pattern 
  2. C Program to Print Given Triangle 
  3. C Program to Print 1800 Rotation of Simple Pyramid
  4. C Program to Print Inverted Pyramid 
  5. C Program to Print Number Pattern
  6. C Program to Print Character Pattern  
  7. C Program to Print Continuous Character Pattern
  8. C Program to Print Hollow Star Pyramid
  9. C Program to Print Inverted Hollow Star pyramid 
  10. C Program to Print Hollow Star Pyramid in a Diamond Shape
  11. C Program to Print Full Diamond Shape Pyramid
  12. C Program to Print Pascal’s Pattern Triangle Pyramid 
  13. C Program to Print Floyd’s Pattern Triangle Pyramid 
  14. C Program to Print Reverse Floyd pattern Triangle Pyramid 

C Program – Functions

  1. C Program to Check Prime Number By Creating a Function 
  2. C Program to Display Prime Numbers Between Two Intervals Using Functions 
  3. C Program to Find All Roots of a Quadratic Equation
  4. C Program to Check Whether a Number can be Express as Sum of Two Prime Numbers
  5. C Program to Find the Sum of Natural Numbers using Recursion 
  6. C Program to Calculate the Factorial of a Number Using Recursion 
  7. C Program to Find G.C.D Using Recursion
  8. C Program to Reverse a Stack using Recursion
  9. C Program to Calculate Power Using Recursion

C Program – Arrays

  1. C Program to Print a 2D Array
  2. C Program to Find the Largest Element in an Array
  3. C Program to Find the Maximum and Minimum in an Array
  4. C Program to Search an Element in an Array (Binary search)
  5. C Program to Calculate the Average of All the Elements Present in an Array 
  6. C Program to Sort an Array using Bubble Sort
  7. C Program to Sort an Array using Merge Sort
  8. C Program to Sort an Array Using Selection Sort 
  9. C Program to Sort an Array Using Insertion Sort
  10. C Program to Sort the Elements of an Array in Descending Order
  11. C Program to Sort the Elements of an Array in Ascending Order 
  12. C Program to Remove Duplicate Elements From a Sorted Array
  13. C Program to Merge Two Arrays 
  14. C Program to Remove All Occurrences of an Element in an Array 
  15. C Program to Find Common Array Elements  
  16. C Program to Copy All the Elements of One Array to Another Array
  17. C Program For Array Rotation 
  18. C Program to Sort the 2D Array Across Rows
  19. C Program to Check Whether Two Matrices Are Equal or Not 
  20. C Program to Find the Transpose
  21. C Program to Find the Determinant of a Matrix
  22. C Program to Find the Normal and Trace 
  23. C Program to Add Two Matrices
  24. C Program to Multiply Two Matrices
  25. C Program to Print Boundary Elements of a Matrix 
  26. C Program to Rotate Matrix Elements 
  27. C Program to Compute the Sum of Diagonals of a Matrix 
  28. C Program to Interchange Elements of First and Last in a Matrix Across Rows 
  29. C Program to Interchange Elements of First and Last in a Matrix Across Columns 

C Program – Strings

  1. C Program to Add or Concatenate Two Strings
  2. C Program to Add 2 Binary Strings
  3. C Program to Get a Non-Repeating Character From the Given String
  4. C Program to check if the string is palindrome or not
  5. C Program to Reverse an Array or String
  6. C program to Reverse a String Using Recursion
  7. C Program to Find the Length of a String
  8. C Program to Sort a String
  9. C Program to Check For Pangram String
  10. C Program to Print the First Letter of Each Word 
  11. C Program to Determine the Unicode Code Point at a Given Index 
  12. C Program to Remove Leading Zeros 
  13. C Program to Compare Two Strings
  14. C Program to Compare Two Strings Lexicographically 
  15. C Program to Insert a String into Another String
  16. C Program to Split a String into a Number of Sub-Strings 

C Program – Conversions

  1. C Program For Boolean to String Conversion 
  2. C Program For Float to String Conversion
  3. C Program For Double to String Conversion 
  4. C Program For String to Long Conversion
  5. C Program For Long to String Conversion
  6. C Program For Int to Char Conversion 
  7. C Program For Char to Int Conversion 
  8. C Program For Octal to Decimal Conversion 
  9. C Program For Decimal to Octal Conversion
  10. C Program For Hexadecimal to Decimal Conversion 
  11. C Program For Decimal to Hexadecimal Conversion 
  12. C Program For Decimal to Binary Conversion 
  13. C Program For Binary to Decimal Conversion

C Program – Pointers

  1. How to Return a Pointer from a Function in C
  2. How to Declare a Two-Dimensional Array of Pointers in C?
  3. C Program to Find the Largest Element in an Array using Pointers
  4. C Program to Swap Two Numbers
  5. C Program to Sort an Array using Pointers
  6. C Program to Sort a 2D Array of Strings
  7. C Program to Check if a String is a Palindrome using Pointers
  8. C Program to Create a Copy of a Singly Linked List using Recursion

C Program – Structures and Unions

  1. C Program to Store Information of Students Using Structure
  2. C Program to Store Student Records as Structures and Sort them by Name
  3. C Program to Add N Distances Given in inch-feet System using Structures
  4. C Program to Add Two Complex Numbers by Passing Structure to a Function
  5. C Program to Store Student Records as Structures and Sort them by Age or ID
  6. Read/Write Structure to a File in C 
  7. Flexible Array Members in a Structure in C

C Program – File IO

  1. C Program to Create a Temporary File
  2. C Program to Read/Write Structure to a File
  3. C Program to Rename a file
  4. C Program to Make a File Read-Only
  5. C program to Compare Two Files and Report Mismatches
  6. C Program to Copy One File into Another File 
  7. C Program to Print all the Patterns that Match Given Pattern From a File
  8. C Program to Append the Content of One Text File to Another
  9. C Program to Read Content From One File and Write it Into Another File
  10. C Program to Read and Print all Files From a Zip File 

C Program – Date and Time

  1. C Program to Format time in AM-PM format 
  2. C program to Print Digital Clock with the Current Time
  3. C Program to Display Dates of Calendar Year in Different Formats
  4. C Program to Display Current Date and Time
  5. C Program to Maximize Time by Replacing ‘_’ in a Given 24-Hour Format Time
  6. C Program to Convert the Local Time to GMT
  7. C Program to Convert Hours into Minutes and Seconds

C Program – More C Programs

  1. C Program to Show Runtime exceptions 
  2. C Program to Show Types of errors 
  3. C Program to Show Unreachable Code Error 
  4. C Program to Find Quotient and Remainder 
  5. C Program to Find the Initials of a Name 
  6. C Program to Draw a Circle in Graphics
  7. Printing Source Code of a C Program Itself


Next Article
C Multiple Choice Questions
author
abhishek1
Improve
Article Tags :
  • C Language
  • C Programs

Similar Reads

  • C File Handling Programs
    C Program to list all files and sub-directories in a directory C Program to count number of lines in a file C Program to print contents of file C Program to copy contents of one file to another file C Program to merge contents of two files into a third file C program to delete a file
    1 min read
  • C Functions
    A function in C is a set of statements that when called perform some specific tasks. It is the basic building block of a C program that provides modularity and code reusability. The programming statements of a function are enclosed within { } braces, having certain meanings and performing certain op
    10 min read
  • Commonly Asked C Programming Interview Questions | Set 3
    Q.1 Write down the smallest executable code? Ans. main is necessary for executing the code. Code is [GFGTABS] C void main() { } [/GFGTABS]Output Q.2 What are entry control and exit control loops? Ans. C support only 2 loops: Entry Control: This loop is categorized in 2 part a. while loop b. for loop
    6 min read
  • Output of C programs | Set 66 (Accessing Memory Locations)
    Q1. Is the output of this code True or False? #include <stdio.h> int main(void) { int b = 20; int* y = &b; char n = 'A'; char* z = &n; y[0] = z[0]; printf((*y == *z) ? "True" : "False"); } A. True B. False C. Program would crash D. Compilation error Answer: A. True
    7 min read
  • C Multiple Choice Questions
    C is the most popular programming language developed by Dennis Ritchie at the Bell Laboratories in 1972 to develop the UNIX operating systems. It is a general-purpose and procedural programming language. It is faster than the languages like Java and Python. C is very versatile it can be used in both
    4 min read
  • 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 U
    12 min read
  • C program to Find the Largest Number Among Three Numbers
    Given 3 integer numbers, the task is to find the largest number among them. Examples Input: a = 10, b = 22, c = 19Output: 22 is the largest number.Explanation: Among the numbers 5, 8, and 3, the largest number is 8.Input: a = 12, b = 7, c = 9Output: 12 is the largest number.Explanation: Among the nu
    4 min read
  • Getting started with C
    C language is a popular programming language that was developed in 1970 by Dennis Ritchie at Bell Labs. The C programming language was developed primarily to build the UNIX operating system. It is widely used because it is simple, powerful, efficient, and portable. Features of C Programming Language
    5 min read
  • LMNs-C Programming
    C programming is a powerful and widely-used programming language that forms the backbone of many modern technologies. Known for its simplicity and efficiency, it is the foundation for learning advanced programming concepts. C programming is a powerful and widely-used programming language that forms
    7 min read
  • Structure of the C Program
    The basic structure of a C program is divided into 6 parts which makes it easy to read, modify, document, and understand in a particular format. C program must follow the below-mentioned outline in order to successfully compile and execute. Debugging is easier in a well-structured C program. Section
    5 min read
geeksforgeeks-footer-logo
Corporate & Communications Address:
A-143, 7th Floor, Sovereign Corporate Tower, Sector- 136, Noida, Uttar Pradesh (201305)
Registered Address:
K 061, Tower K, Gulshan Vivante Apartment, Sector 137, Noida, Gautam Buddh Nagar, Uttar Pradesh, 201305
GFG App on Play Store GFG App on App Store
Advertise with us
  • Company
  • About Us
  • Legal
  • Privacy Policy
  • In Media
  • Contact Us
  • Advertise with us
  • GFG Corporate Solution
  • Placement Training Program
  • Languages
  • Python
  • Java
  • C++
  • PHP
  • GoLang
  • SQL
  • R Language
  • Android Tutorial
  • Tutorials Archive
  • DSA
  • Data Structures
  • Algorithms
  • DSA for Beginners
  • Basic DSA Problems
  • DSA Roadmap
  • Top 100 DSA Interview Problems
  • DSA Roadmap by Sandeep Jain
  • All Cheat Sheets
  • Data Science & ML
  • Data Science With Python
  • Data Science For Beginner
  • Machine Learning
  • ML Maths
  • Data Visualisation
  • Pandas
  • NumPy
  • NLP
  • Deep Learning
  • Web Technologies
  • HTML
  • CSS
  • JavaScript
  • TypeScript
  • ReactJS
  • NextJS
  • Bootstrap
  • Web Design
  • Python Tutorial
  • Python Programming Examples
  • Python Projects
  • Python Tkinter
  • Python Web Scraping
  • OpenCV Tutorial
  • Python Interview Question
  • Django
  • Computer Science
  • Operating Systems
  • Computer Network
  • Database Management System
  • Software Engineering
  • Digital Logic Design
  • Engineering Maths
  • Software Development
  • Software Testing
  • DevOps
  • Git
  • Linux
  • AWS
  • Docker
  • Kubernetes
  • Azure
  • GCP
  • DevOps Roadmap
  • System Design
  • High Level Design
  • Low Level Design
  • UML Diagrams
  • Interview Guide
  • Design Patterns
  • OOAD
  • System Design Bootcamp
  • Interview Questions
  • Inteview Preparation
  • Competitive Programming
  • Top DS or Algo for CP
  • Company-Wise Recruitment Process
  • Company-Wise Preparation
  • Aptitude Preparation
  • Puzzles
  • School Subjects
  • Mathematics
  • Physics
  • Chemistry
  • Biology
  • Social Science
  • English Grammar
  • Commerce
  • World GK
  • GeeksforGeeks Videos
  • DSA
  • Python
  • Java
  • C++
  • Web Development
  • Data Science
  • CS Subjects
@GeeksforGeeks, Sanchhaya Education Private Limited, All rights reserved
We use cookies to ensure you have the best browsing experience on our website. By using our site, you acknowledge that you have read and understood our Cookie Policy & Privacy Policy
Lightbox
Improvement
Suggest Changes
Help us improve. Share your suggestions to enhance the article. Contribute your expertise and make a difference in the GeeksforGeeks portal.
geeksforgeeks-suggest-icon
Create Improvement
Enhance the article with your expertise. Contribute to the GeeksforGeeks community and help create better learning resources for all.
geeksforgeeks-improvement-icon
Suggest Changes
min 4 words, max Words Limit:1000

Thank You!

Your suggestions are valuable to us.

What kind of Experience do you want to share?

Interview Experiences
Admission Experiences
Career Journeys
Work Experiences
Campus Experiences
Competitive Exam Experiences