Lesson 1 of 60 – Introduction to C Programming
2%

Introduction to C Programming

C is a general-purpose programming language used to create software, operating systems, embedded systems, games, utilities, and many other types of applications.

C is one of the most important programming languages for beginners because it helps students understand programming fundamentals such as variables, data types, operators, conditions, loops, functions, arrays, pointers, structures, and memory management.

Note: In this tutorial, we will learn C programming from basic concepts to practical programming step by step.

1. What is C?

C is a general-purpose, procedural programming language. It was designed to provide a simple and efficient way to write computer programs.

C allows programmers to work with both high-level programming concepts and low-level computer operations.

#include <stdio.h>

int main()
{
    printf("Hello World");

    return 0;
}

The above program displays Hello World.

2. Why Learn C?

Learning C gives students a strong foundation in programming.

  • Easy to understand programming fundamentals
  • Fast and efficient
  • Helps understand memory
  • Useful for learning other languages
  • Widely used in system programming
  • Useful for data structures and algorithms

C teaches how a program works at a fundamental level.

3. Who Created C?

C was developed by Dennis Ritchie at Bell Labs.

The language was developed during the early 1970s and became an important language for system software development.

C was closely associated with the development of the UNIX operating system.

4. C is a General-Purpose Language

C is called a general-purpose programming language because it can be used for many different types of software.

  • System software
  • Embedded applications
  • Compilers
  • Operating system components
  • Utilities
  • Games
  • Application software

5. Procedural Programming

C primarily follows the procedural programming approach.

A program can be divided into functions or procedures that perform specific tasks.

#include <stdio.h>

void message()
{
    printf("Welcome to C");
}

int main()
{
    message();

    return 0;
}

Here, message() is a function that performs a specific task.

6. C is a Compiled Language

C programs are normally compiled before they are executed.

A compiler translates the C source code into machine code that the computer can execute.

Source Code
     ↓
Compiler
     ↓
Machine Code
     ↓
Program Execution

7. C Source Code

The instructions written by a programmer are called source code.

C source files normally use the .c extension.

hello.c

A C compiler processes this source file to create an executable program.

8. First C Program

Let's look at a simple C program.

#include <stdio.h>

int main()
{
    printf("Hello World");

    return 0;
}

This program displays:

Hello World

9. The main() Function

The main() function is the entry point of a C program. Execution begins from the main() function.

int main()
{
    printf("Hello");
    return 0;
}

A program can contain many functions, but execution starts from main().

10. The #include Directive

The #include directive is used to include a header file in a C program.

#include <stdio.h>

The stdio.h header provides declarations for standard input and output functions such as printf() and scanf().

11. What is stdio.h?

stdio.h is a standard C header file related to input and output operations.

It contains declarations for functions such as:

  • printf()
  • scanf()
  • getchar()
  • putchar()
#include <stdio.h>

12. The printf() Function

The printf() function is commonly used to display output.

#include <stdio.h>

int main()
{
    printf("Welcome to C Programming");

    return 0;
}

Output:

Welcome to C Programming

13. Statements in C

A statement is an instruction that tells the computer to perform an operation.

Most C statements end with a semicolon ;.

printf("Hello");
return 0;

The semicolon marks the end of these statements.

14. Curly Braces

Curly braces { } are used to define a block of code.

int main()
{
    printf("Hello");
    return 0;
}

The statements inside the braces belong to the main() function.

15. Comments in C

Comments are notes written inside source code. They are ignored by the compiler.

Single-line comment:

// This is a comment

Multi-line comment:

/*
   This is a
   multi-line comment
*/

16. Variables in C

A variable is a named memory location used to store data.

int age = 20;

Here:

  • int is the data type.
  • age is the variable name.
  • 20 is the value.

17. Data Types

A data type tells the compiler what type of data a variable can store.

Common C data types include:

  • int – integer values
  • float – floating-point values
  • double – double-precision floating-point values
  • char – character values
int age = 20;
float price = 25.50;
char grade = 'A';

18. Taking Input in C

The scanf() function can be used to take formatted input from the user.

#include <stdio.h>

int main()
{
    int age;

    printf("Enter age: ");
    scanf("%d", &age);

    printf("Age = %d", age);

    return 0;
}

19. Operators in C

Operators are symbols used to perform operations on values and variables.

Examples include:

+
-
*
/
%
==
>
<

C provides arithmetic, relational, logical, assignment, bitwise, and other operators.

20. Conditional Statements

Conditional statements allow a program to make decisions.

int age = 20;

if(age >= 18)
{
    printf("Adult");
}

The if statement executes its block when the condition is true.

21. Loops in C

Loops are used to execute a block of code repeatedly.

Common loops in C are:

  • for loop
  • while loop
  • do-while loop
for(int i = 1; i <= 5; i++)
{
    printf("%d\n", i);
}

22. Functions in C

A function is a block of code designed to perform a particular task.

void hello()
{
    printf("Hello");
}

Functions help divide a large program into smaller and reusable parts.

23. Arrays in C

An array stores multiple values of the same type under one variable name.

int numbers[5] = {
    10, 20, 30, 40, 50
};

Array indexing normally starts from 0.

printf("%d", numbers[0]);

24. Strings in C

A string in C is stored as an array of characters terminated by a null character.

char name[] = "Rahul";

printf("%s", name);

The %s format specifier is commonly used with strings in formatted input and output functions.

25. Pointers in C

A pointer is a variable that stores a memory address.

int age = 20;

int *ptr = &age;

Here, ptr stores the address of the variable age.

Pointers are an important part of C programming.

26. Structures in C

A structure allows different types of data to be grouped together under one user-defined type.

struct Student
{
    int age;
    char grade;
};

Structures are useful for representing related information.

27. File Handling

C provides functions for working with files.

Common file operations include:

  • Opening a file
  • Reading a file
  • Writing to a file
  • Appending data
  • Closing a file
FILE *file;

28. Where is C Used?

C is used in many areas of computing.

  • Operating systems
  • Embedded systems
  • Device drivers
  • Compilers
  • System utilities
  • Networking software
  • Microcontrollers
  • Performance-sensitive software

29. C and Other Programming Languages

Learning C can make it easier to understand fundamental programming concepts used in many other languages.

Concepts such as variables, conditions, loops, functions, arrays, and data structures are also found in languages such as C++, Java, C#, and other programming languages.

C also provides a useful foundation for understanding memory and low-level programming concepts.

30. What You Will Learn in This C Tutorial

Throughout this 60-lesson C tutorial, you will gradually learn:

  • C syntax and program structure
  • Variables and constants
  • Data types
  • Input and output
  • Operators
  • Conditional statements
  • Loops
  • Functions
  • Arrays
  • Strings
  • Pointers
  • Structures and unions
  • Dynamic memory allocation
  • File handling
  • Preprocessor directives
  • Practical C programs
  • A complete C mini project

By the end of the course, you will have a strong foundation for writing and understanding C programs.

📌 Key Points

  • C is a general-purpose procedural programming language.
  • C was developed by Dennis Ritchie at Bell Labs.
  • C programs are normally compiled before execution.
  • The main() function is the entry point of a C program.
  • stdio.h provides declarations for standard input and output functions.
  • printf() is commonly used for displaying output.
  • scanf() is commonly used for formatted input.
  • Variables are used to store data.
  • Conditions allow programs to make decisions.
  • Loops allow programs to repeat operations.
  • Functions divide programs into reusable blocks.
  • Arrays store multiple values of the same type.
  • Pointers store memory addresses.
  • Structures group related data together.

🧠 Quick Quiz

Question: Who developed the C programming language at Bell Labs?