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)
Top Articles
Latest Posts
Article information

Author: Nicola Considine CPA

Last Updated:

Views: 5821

Rating: 4.9 / 5 (49 voted)

Reviews: 88% of readers found this page helpful

Author information

Name: Nicola Considine CPA

Birthday: 1993-02-26

Address: 3809 Clinton Inlet, East Aleisha, UT 46318-2392

Phone: +2681424145499

Job: Government Technician

Hobby: Calligraphy, Lego building, Worldbuilding, Shooting, Bird watching, Shopping, Cooking

Introduction: My name is Nicola Considine CPA, I am a determined, witty, powerful, brainy, open, smiling, proud person who loves writing and wants to share my knowledge and understanding with you.