C Programming Language Tutorial - GeeksforGeeks (2024)

Last Updated : 10 Jun, 2024


In thisC Tutorial, you’ll learn all C programming basic to advanced concepts like variables, arrays, pointers, strings, loops, etc. This C Programming Tutorial is designed for both beginners as well as experienced professionals, who’re looking to learn and enhance their knowledge of the C programming language.

What is C?

C is a general-purpose, procedural, high-level programming language used in the development of computer software and applications, system programming, games, and more.

  • C language was developed byDennis M. Ritchieat the Bell Telephone Laboratories in1972.
  • It is a powerful and flexible language which was first developed for the programming of theUNIX operating System.
  • C is one of the most widely used programming languages.

C programming languageis known for its simplicity and efficiency. It is the best choice to start with programming as it gives you a foundational understanding of programming.

C Programming Language Tutorial - GeeksforGeeks (1)

Getting Started With C Tutorial

Start your coding adventure with our free C Tutorial. A perfect C programming tutorial for beginners and advanced coders alike, this tutorial is your key to unlocking the magic of C programming. With clear explanations and fun examples.

Table of Content

  • C Basics
  • C Variables and Constants
  • C Data Types
  • C Input/Output
  • C Operators
  • CControl Statements Decision-Making
  • C Functions
  • C Pointers
  • C User-Defined Data Types
  • C Storage Classes
  • C Memory Management
  • C Preprocessor
  • C File Handling
  • C Error Handling
  • C Programs
  • Miscellaneous
  • C Interview Questions

C Basics

  • C Language Introduction
  • Features of C Programming Language
  • C Programming Language Standard
  • Setting Up C Development Environment
  • C Hello World Program
  • Compiling a C Program: Behind the Scenes
  • C Comments
  • Tokens in C
  • C Identifiers
  • Keywords in C

C Variables and Constants

  • C Variables
  • Constants in C
  • Const Qualifier in C
  • Different Ways to Declare Variable as Constant in C
  • Scope Rules in C
  • Internal Linkage and External Linkage in C
  • Global Variables in C

C Data Types

  • Data Types in C
  • Data Type Modifiers in C
  • Literals in C
  • Escape Sequence in C
  • bool in C
  • Integer Promotions in C
  • Character Arithmetic in C
  • Type Conversion in C

C Input/Output

  • Basic Input and Output in C
  • Format Specifiers in C
  • printf in C
  • scanf in C
  • Scansets in C
  • Formatted and Unformatted Input and Output Functions

C Operators

  • Operators in C
  • Arithmetic Operators in C
  • Unary Operators in C
  • Relational Operators in C
  • Bitwise Operators in C
  • Logical Operators in C
  • Assignment Operators in C
  • Increment and Decrement Operators in C
  • Conditional or Ternary Operator (?:) in C
  • size of Operator in C
  • Operator Precedence and Associativity in C

CControl Statements Decision-Making

  • Decision-Making in C
  • C if Statement
  • C if…else Statement
  • C if-else-if Ladder
  • Switch Statement in C
  • Using Range in switch case in C
  • Loops in C
  • C for Loop
  • while looping in C
  • do…while Loop in C
  • for versus while Loop
  • continue Statement in C
  • break Statement in C
  • goto Statement in C

C Functions

  • C Functions
  • User-Defined Function in C
  • Parameter Passing Techniques in C
  • Importance of Function Prototype in C
  • Return Multiple Values From a Function
  • main Function in C
  • Implicit Return Type int in C
  • Callbacks in C
  • Nested Functions in C
  • Variadic functions in C
  • _Noreturn Function Specifier in C
  • Predefined Identifier __func__ in C
  • Maths Functions in C

C Arrays & Strings

  • C Arrays
  • Properties of Array in C
  • Multidimensional Arrays in C
  • Initialization of Multidimensional Arrays in C
  • Pass Array to Functions in C
  • Pass a 2D Array as a Parameter in C
  • Data Types for Which Array is Not Possible
  • Pass an Array by Value in C
  • Strings in C
  • An Array of Strings in C
  • Difference Between Single Quoted and Double Quoted Initialization
  • String Functions in C

C Pointers

  • C Pointers
  • Pointer Arithmetics in C
  • Pointer to Pointer (Double Pointer) in C
  • Function Pointer in C
  • Declare Function Pointer in C
  • Pointer to an Array in C
  • Constant Pointer in C
  • Pointer vs Array in C
  • Dangling, Void, Null and Wild Pointers
  • Near, Far and Huge Pointers in C
  • restrict Keyword in C

C User-Defined Data Types

  • C Structures
  • dot (.) Operator in C
  • C typedef
  • Structure Member Alignment, Padding and Data Packing
  • Flexible Array Members in a Structure in C
  • C Unions
  • Bit Fields in C
  • Difference Between Structure and Union in C
  • Anonymous Union and Structure in C
  • Enumeration (or enum) in C

C Storage Classes

  • Storage Classes in C
  • extern Keyword in C
  • Static Variables in C
  • Initialization of Static Variables in C
  • Static Functions in C
  • Understanding “volatile” Qualifier in C
  • Understanding the “register” Keyword in C

C Memory Management

  • Memory Layout of C Programs
  • Dynamic Memory Allocation in C
  • Difference Between malloc() and calloc()
  • What is a Memory Leak?
  • Dynamic Array in C
  • Dynamically Allocate a 2D Array in C
  • Dynamically Growing Array in C

C Preprocessor

  • C Preprocessors
  • C Preprocessor Directives
  • How a Preprocessor Works in C?
  • Header Files in C
  • Difference Between Header Files “stdio.h” and “stdlib.h”
  • Write Your Own Header File in C
  • Macros and their Types in C
  • Interesting Facts About Macros and Preprocessors in C
  • # and ## Operators in C
  • Print a Variable Name in C
  • Multiline Macros in C
  • Variable Length Arguments for Macros
  • Branch Prediction Macros in GCC
  • typedef versus #define in C
  • Difference Between #define and const in C

C File Handling

  • Basics of File Handling in C
  • C fopen() Function
  • EOF, getc() and feof() in C
  • fgets() and gets() in C
  • fseek() vs rewind() in C
  • Return Type of getchar(), fgetc() and getc()
  • Read/Write Structure From/to a File in C
  • C Program to Print Contents of File
  • C Program to Delete a File
  • C Program to Merge Contents of Two Files into a Third File
  • Difference Between printf, sprintf and fprintf
  • Difference Between getc(), getchar(), getch() and getche()

C Error Handling

  • Error Handling in C
  • Using goto for Exception Handling in C
  • Error Handling During File Operations in C
  • C Program to Handle Divide By Zero and Multiple Exceptions

C Programs

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


  • Date and Time in C
  • Input-output system calls in C
  • Signals in C
  • Program Error Signals in C
  • Socket Programming in C
  • _Generics Keyword in C
  • Multithreading in C

C Interview Questions

  • Top 50 C Programming Interview Questions and Answers
  • Commonly Asked C Programming Interview Questions | Set 1
  • Commonly Asked C Programming Interview Questions | Set 2
  • Commonly Asked C Programming Interview Questions | Set 3

Why Learn C?

C programming language is one of the most popular programming language. It is a must learn for software engineering students. C is called the mother of all modern programming languages so learning C will help you to learn other languages easily like Java, C++, C#, Python, etc. C language is faster than other programming languages like Java and Python. It can handle low-level programming and we can compile the C code in a variety of computer platforms.

List of somekey advantages of C language:

  • Easy to learn.
  • Versatile Language, which can be used in both applications and technologies.
  • Mid-Level Programming Language.
  • Structured Programming Language.

C Compiler

C compiler is a software that translates human-readable C language code into machine code or an intermediate code that can be executed by a computer’s central processing unit (CPU).

There are manyC compilersavailable in the market, such asGNU Compiler Collection (GCC),Microsoft Visual C++ Compiler,Clang,Intel C++ Compiler, andTinyCC (TCC).

For this tutorial, we will be using the GNU-based online C compiler provided by GeeksforGeeks which is developed for beginners and is very easy to use compared to other compiler/IDE’s available on the web.

Print Hello World using C Programming

#include <stdio.h> int main() {printf("Hello World! I Don't Give a Bug");return 0;}


Hello World! I Don't Give a Bug

“Give this C code a try, and here’s a fun challenge: print ‘Hello World’ along with your name!”

Features of C Language

There are some key features of C language that show the ability and power of C language:

  • Simplicity and Efficiency:The simple syntax and structured approach make the C language easy to learn.
  • Fast Speed:C is one of the fastest programming language because C is a static programming language, which is faster than dynamic languages like Java and Python. C is also a compiler-based which is the reason for faster code compilation and execution.
  • Portable:C provides the feature that you write code once and run it anywhere on any computer. It shows the machine-independent nature of the C language.
  • Memory Management:C provides lower level memory management using pointers and functions like realloc(), free(), etc.
  • Pointers:C comes with pointers. Through pointers, we can directly access or interact with the memory. We can initialize a pointer as an array, variables, etc.
  • Structured Language:C provides the features of structural programming that allows you to code into different parts using functions which can be stored as libraries for reusability.

Applications of C Language

C was used in programs that were used in making operating systems. C was known as a system development language because the code written in C runs as fast as the code written in assembly language.

The use of C is given below:

  • Operating Systems
  • Language Compilers
  • Assemblers
  • Text Editors
  • Print Spoolers
  • Network Drivers
  • Modern Programs
  • Databases
  • Language Interpreters
  • Utilities

FAQs on C Language

Q1. How to learn C easily?


The first steps towards learning C or any language are to write a hello world program. It gives the understanding of how to write and execute a code. After this, learn the following:

  • Variables
  • Operators
  • Conditionals
  • Loops and Errors
  • Arrays and Strings
  • Pointers and Memory
  • Functions
  • Structures
  • Recursions

Q2. Difference between C and C++?




C is a procedural programming language.

C++ is both a procedural and object-oriented programming language.

It does not support Function overloading.

It supports function overloading.

Operator overloading is not supported.

Operator overloading is supported.

C does not support data hiding which leads to security concerns.

Data hiding is supported in C++ by Data Encapsulation.

Q3. Is C easy to learn for beginners?


While C is one of the easy languages, it is still a good first language choice to start with because almost all programming languages are implemented in it. It means that once you learn C language, it’ll be easy to learn more languages like C++, Java, and C#.

Q4. Why should we learn C first rather than C++?


C is a ‘mother of all languages.’ It provides a solid understanding of fundamental programming concepts and is considered easier to grasp. C offers versatile applications, from software development to game programming, making it an excellent choice for building a strong programming foundation.

C Programming Language Tutorial - GeeksforGeeks (2)



Next Article

C Language Introduction

Please Login to comment...

C Programming Language Tutorial - GeeksforGeeks (2024)


Is GeeksforGeeks.org reliable? ›

Over the years, the platform has experienced exponential growth, cementing its position as one of the most trusted and renowned names in the programming community.

Is GeeksforGeeks good for beginners? ›

GeeksforGeeks is a valuable resource for anyone on their tech journey, from curious beginners to seasoned programmers.

Why is C so much harder than Python? ›

The syntax of a C program is harder than Python. Python uses an automatic garbage collector for memory management. In C, the Programmer has to do memory management on their own. Python is a General-Purpose programming language.

Is GeeksforGeeks an Indian company? ›

GeeksforGeeks's main headquarters is located at NOIDA, G. B. Nagar, Uttar Pradesh IN. The company has employees across 6 continents, including AsiaNorth AmericaEurope.

Is GeeksforGeeks a valid source? ›

It has a large global user base and is considered a reliable source for learning programming and computer science topics.

Can I get GeeksforGeeks courses for free? ›

These courses provided by GeeksforGeeks are absolutely free and bring the best quality content be it video-based or theoretical.

What is the hardest C language to learn? ›

C++ is considered to be one of the most powerful, fastest, and toughest programming languages.

How long does it take to fully learn C? ›

If you are a beginner with no programming experience, you should expect it to take at least three months to learn the basics. If you have programmed before, it may only take you a month or two. To build mastery in C++, you should expect to spend at least two years working on improving your skills a little each day.

Why is C so easy to learn? ›

C is a small language. There are few keywords and syntax rules. So it's quite easy to learn and memorise this. But there is a big complexity in how to actually make use of these keywords in a good way.

Is Java or C harder? ›

Is C or Java easier to learn? It's a general consensus that Java is easier to learn because its syntax is closer to natural language than C.

What is the fastest programming language? ›

C and C++

C is considered to be the fastest programming language for low-level development. C is optimal for low-level programs, and C++ is best for commercial applications. These languages have similar syntax but C++, a C subset, is considerably broader.

Which is harder, C or C++? ›

C does not have so many rules and restrictins as C++ it is not so difficult to learn it because it is more direct to code. On other hand the C++ is more powefull to use. The conclusion is C is easier to learn, C++ is easier to use.

Is GeeksforGeeks a good resource? ›

In the digital age, finding a reliable and comprehensive learning platform is challenging. GeeksforGeeks stands out as a one-stop solution for computer science students with its extensive range of tutorials, courses, and preparation materials for placements and interviews.

Who runs GeeksforGeeks? ›

Sandeep Jain

Mr. Sandeep Jain is the founder at GeeksforGeeks. He is an alumini of Indian Institute of Technology Roorkee. His platform GeeksforGeeks is well recognized among all the engineering students throughout all colleges in India.

Is a GeeksforGeeks certificate valid? ›

For offline courses GFG does provide certification, as it has always been pre-mentioned in their courses. But no certification would be provided for Free online courses. And If there is some other type of Participation you want to ask, do tell… I would be happy to answer.

Which country owns GeeksforGeeks? ›

Intro and history: GeeksforGeeks (GFG) is a computer science portal founded by Sandeep Jain in 2009. It started as a blog to share computer science concepts and has grown into a comprehensive platform for learning and practicing coding. It is based in Noida, Uttar Pradesh, India.


Top Articles
Latest Posts
Article information

Author: Rubie Ullrich

Last Updated:

Views: 6449

Rating: 4.1 / 5 (52 voted)

Reviews: 83% of readers found this page helpful

Author information

Name: Rubie Ullrich

Birthday: 1998-02-02

Address: 743 Stoltenberg Center, Genovevaville, NJ 59925-3119

Phone: +2202978377583

Job: Administration Engineer

Hobby: Surfing, Sailing, Listening to music, Web surfing, Kitesurfing, Geocaching, Backpacking

Introduction: My name is Rubie Ullrich, I am a enthusiastic, perfect, tender, vivacious, talented, famous, delightful person who loves writing and wants to share my knowledge and understanding with you.