Skip to content
StudyFame

What is C Programming Language?

C is a programming language. We use it to give instructions to a computer.

It was made by Dennis Ritchie at Bell Labs in 1972. It is more than 50 years old, but it is still used everywhere: in operating systems, mobile phones, cars, washing machines and databases.

In this lesson you will learn what C is, why it is important, and how a C program runs.

What You Will Learn

  • What C is, in simple words.
  • Why C is called a middle-level and compiled language.
  • Where C is used today.
  • The basic structure of a C program.
  • How to write your first C program.
  • The 4 steps a C program goes through before it runs.

C Programming Language Explained

Exam definition: C is a general-purpose, procedural, middle-level programming language. It was developed by Dennis Ritchie at Bell Labs in 1972 to write the UNIX operating system.

What is a programming language?

A programming language is how we write code: the words (keywords) and rules we use to tell the computer what to do.

Different programming languages are used for different purposes:

  • JavaScript is good for web development.
  • Python is good for AI.
  • C / C++ is good for programming microcontrollers.

Features of the C language

C has four main features. Remember these four words:

FeatureSimple meaning
General-purposeYou can make almost any kind of program with it: games, calculators, operating systems.
ProceduralThe program runs step by step, from top to bottom, using functions.
CompiledThe whole program is converted to machine code before it runs.
Middle-levelIt is easy to read like a high-level language, and it can also control memory like a low-level language.

Memory trick: C is a bridge. On one side is the human (easy language), on the other side is the machine (memory and hardware). C stands in the middle, so it is called a middle-level language.

Compiled vs interpreted languages

Compiled (C, C++)Interpreted (Python, JavaScript)
How it convertsWhole program at onceOne line at a time
WhenBefore the program runsWhile the program runs
ResultAn .exe (executable) fileNo separate file
SpeedFastSlower

Easy example: a compiler is like translating a whole book first and then reading it. An interpreter is like translating one line, reading it, then translating the next line.

A short history of C

YearWhat happened
1967 – 1970BCPL and then B language were used at Bell Labs.
1972Dennis Ritchie made C from B. UNIX was rewritten in C.
1978The famous book The C Programming Language by Kernighan and Ritchie ("K&R C").
1989 / 1990First official standard: ANSI C (also called C89 / C90).
1999 – 2024Newer versions: C99, C11, C17 and C23.

Memory trick: B came before C, just like in the alphabet. Full order: BCPL → B → C.

Why learn C today?

  • It shows you how a computer really works (memory, data, execution).
  • C++, Java, C# and JavaScript look similar to C. Learn C first, and these become easy.
  • C is a core subject in B.Tech, BCA, MCA and most computer courses.

Basic Syntax of a C Program

Every C program follows this basic structure:

#include <header_file.h>

int main(void)
{
    /* your code goes here */
    return 0;
}
PartWhat it does
#include <header_file.h>Adds ready-made code. Example: stdio.h gives us printf() to print on the screen.
int main(void)The main function. Every C program starts here.
{ }Curly braces show where main starts and ends.
/* … */A comment. A note for humans. The computer ignores it.
return 0;Ends the program and says "everything went fine".

Example 1: Hello World Program in C

This is the first program everyone writes. It prints a message on the screen.

#include <stdio.h>

int main(void)
{
    printf("Hello, World!\n");
    return 0;
}

Output

Hello, World!

Hello World Program Explained Line by Line

  1. #include <stdio.h>: adds the file stdio.h (standard input output). It contains printf().
  2. int main(void): the program starts running from here.
  3. {: start of main.
  4. printf("Hello, World!\n");: prints the text inside the double quotes. \n means new line. The semicolon ; ends the statement.
  5. return 0;: ends the program successfully.
  6. }: end of main.

How a C Program is Compiled and Run

You write your program in a file called hello.c. The computer cannot run this file directly. It goes through 4 steps:

StepWho does itWhat happens
1. PreprocessingPreprocessorHandles lines starting with # (like #include) and removes comments.
2. CompilationCompilerChecks for errors and converts the code to assembly code.
3. AssemblyAssemblerConverts assembly code to machine code (object file hello.o).
4. LinkingLinkerJoins your code with library code (like printf) and makes the final .exe file.

Memory trick: P-C-A-L = "Please Compile And Link". Preprocessing → Compilation → Assembly → Linking.

With the GCC compiler, you need only two commands:

gcc hello.c -o hello     (step 1: compile)
./hello                  (step 2: run on Linux / macOS)
hello.exe                (run on Windows)

When you run it, the computer starts from main() and runs each line from top to bottom.

Example 2: C Program to Calculate Total Marks and Percentage

A simple real-life program: add the marks of three subjects and find the percentage.

#include <stdio.h>

int main(void)
{
    int maths = 78, physics = 85, chemistry = 69;
    int total = maths + physics + chemistry;
    float percentage = total / 3.0f;

    printf("Total marks: %d out of 300\n", total);
    printf("Percentage: %.2f%%\n", percentage);

    return 0;
}

Output

Total marks: 232 out of 300
Percentage: 77.33%

Some words here are new (int, float, %d). Don't worry, each one has its own lesson later. For now, just notice that the structure is the same as Example 1: #include, main(), statements ending with ;, and return 0;.

Important Points to Remember

  • C was made by Dennis Ritchie at Bell Labs in 1972.
  • Every C program has one main() function. The program starts from there.
  • Every statement ends with a semicolon ;.
  • C is case-sensitive: printf is correct, Printf is wrong.
  • C files are saved with the .c extension.

Common Mistakes Beginners Make in C

MistakeWhat happensHow to fix
No semicolon: printf("Hi")Error: expected ';'Put ; at the end of every statement
Capital letter: Printf("Hi");Error: Printf is not knownWrite printf in small letters
Forgot #include <stdio.h>Error or warning for printfAlways include the header file
Single quotes: printf('Hi');Error or wrong outputUse double quotes for text: "Hi"
File saved as hello.txtCompiler does not accept itSave the file as hello.c

Uses and Advantages of C Programming

Where is C used?

  • Operating systems: Linux, and parts of Windows and macOS.
  • Embedded systems: chips inside washing machines, cars, ACs and routers.
  • Databases: SQLite, PostgreSQL and MySQL.
  • Other languages: Python itself is written in C.
  • Device drivers: software that controls printers, keyboards and other hardware.

Advantages of C

  • Fast: C programs run very quickly.
  • Portable: the same program can run on different computers.
  • Simple: it has only a small number of keywords to learn.
  • Strong base: after C, learning C++, Java and data structures is easier.

Limitation: C has no classes or objects (no OOP), and you have to manage memory yourself.

Want to practise right away? See our solved C programs with output.

C Programming Practice Questions

  1. Why is C called a middle-level language?
  2. What is the difference between a compiled and an interpreted language?
  3. Write the 4 steps that turn a C file into a running program.
  4. What happens if you remove #include <stdio.h> from Example 1?
  5. What does \n do inside printf()?
Show answers
  1. Because it is easy to read like a high-level language, and it can also work with memory and hardware like a low-level language.
  2. A compiled language converts the whole program before it runs. An interpreted language converts one line at a time while it runs.
  3. Preprocessing → Compilation → Assembly → Linking (P-C-A-L).
  4. The compiler does not know printf(), so it shows an error (old compilers show a warning).
  5. It moves to a new line, so the next output starts on the next line.

Coding Exercise

Write a C program that prints your name, course and college on three lines, like this:

Name: Riya Sharma
Course: B.Tech Computer Science
College: ABC Institute of Technology

Bonus: print a line of * stars above and below.

Show solution
#include <stdio.h>

int main(void)
{
    printf("**********************************\n");
    printf("Name: Riya Sharma\n");
    printf("Course: B.Tech Computer Science\n");
    printf("College: ABC Institute of Technology\n");
    printf("**********************************\n");
    return 0;
}

Quick Quiz: C Programming Basics (MCQ)

  1. Who developed the C language?

    A) Bjarne Stroustrup   B) Dennis Ritchie   C) James Gosling   D) Guido van Rossum

  2. C is a ______ language.

    A) markup   B) query   C) compiled   D) interpreted-only

  3. A C program starts running from:

    A) The first line of the file   B) start()   C) main()   D) printf()

  4. Which header file has printf()?

    A) conio.h   B) stdio.h   C) math.h   D) string.h

  5. What does return 0; in main() mean?

    A) The program failed   B) Print 0 on the screen   C) The program ended successfully   D) Restart the program

Show answers
  1. B: Dennis Ritchie, at Bell Labs, 1972.
  2. C: compiled. The whole program is converted before it runs.
  3. C: main() is where every C program starts.
  4. B: stdio.h (standard input output).
  5. C: 0 means the program ended successfully.

Quick Revision for Exams and Interviews

Read this before your exam or interview. The highlighted words are the answer.

Must-remember facts

Developed byDennis Ritchie
Where and whenBell Labs (AT&T), USA, 1972
Made fromB language (BCPL → B → C)
First made forThe UNIX operating system
Type of languageGeneral-purpose, procedural, compiled, middle-level
First standardANSI C (C89 / C90). Later: C99, C11, C17, C23
Program starts frommain(); only one per program
File extension.c program file, .h header file
4 steps (P-C-A-L)Preprocessing → Compilation → Assembly → Linking
printf() is instdio.h
return 0; meansProgram ended successfully

Frequently asked questions

Why is C called a middle-level language?
It is easy to read like a high-level language and can control memory like a low-level language.
Why is C called the "mother of programming languages"?
C++, Java, C# and JavaScript are based on C's syntax, and many other languages are written in C.
Is C compiled or interpreted?
Compiled. The whole program is converted to machine code before it runs.
Is C case-sensitive?
Yes. printf and Printf are different.
Can a C program run without main()?
No. The program starts from main(). Without it, the linker gives an error.
What does the preprocessor do?
It handles lines starting with # and removes comments, before compilation.
What does the linker do?
It joins your code with library code (like printf) and makes the .exe file.

Remember

  • Every statement ends with ;
  • Text goes in double quotes "…"; \n = new line.
  • Include the header file for every library function.
  • Compile: gcc file.c -o file · Run: ./file

Next Topic

Next lesson: History and Features of C Language. You will learn where C came from, its versions, and the features that make it fast and portable.