Introduction to C

1. What is C Language?

C is a general-purpose programming language developed by Dennis Ritchie in 1972 at Bell Labs.
It is one of the most widely used programming languages and forms the foundation of many modern languages such as C++, Java, and Python.


2. Features of C

  • Simple & Efficient → Easy to learn, fast execution.
  • Portable → Programs can run on different systems.
  • Structured Programming → Supports modular programming with functions.
  • Rich Library → Provides built-in functions for input/output, math, etc.
  • Low-Level Access → Can interact with memory directly (pointers).

 

3. First C Program Here’s the classic "Hello, World!" program in C:

				
					#include <stdio.h>

int main() {
    // print message on the screen
    printf("Hello, World!");
    return 0;
}

				
			

Explanation:

  • #include <stdio.h> → Includes standard input-output library.

  • int main() → Entry point of the program.

  • printf("Hello, World!"); → Displays text on the screen.

  • return 0; → Ends the program successfully.


4. Compilation & Execution

  1. Save the program as hello.c.

  2. Open terminal/command prompt.

  3. Compile the program:

				
					gcc hello.c -o hello

				
			

4.Run the program:

				
					./hello

				
			

5. Basic Structure of a C Program

Every C program generally follows this structure:

				
					#include <stdio.h>   // Header files

int main() {
    // variable declaration
    int a, b, sum;

    // input
    printf("Enter two numbers: ");
    scanf("%d %d", &a, &b);

    // calculation
    sum = a + b;

    // output
    printf("Sum = %d", sum);

    return 0;
}

				
			

6. Applications of C

  • Operating systems (Linux, Windows kernels).

  • Embedded systems (IoT, automotive).

  • Game development.

  • Compilers & interpreters.

  • Database systems (MySQL).