C Programming – Quick Review (Simple & Easy Guide)

C programming quick review

This blog gives a quick review of C programming. All concepts are explained in simple English, with easy examples. Perfect for interviews, exams, and beginners.

1. What is C Programming?

C is a general-purpose programming language.

  • Created by Dennis Ritchie
  • Fast and powerful
  • Used to build operating systems, drivers, embedded systems

Why C is important?

  • Foundation for languages like C++, Java, Python
  • Very fast execution
  • Direct memory access

2. Structure of a C Program

Every C program follows this basic structure:

#include <stdio.h>

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

Explanation:

  • #include → adds header files
  • main() → program starts here
  • printf() → prints output
  • return 0 → program ends successfully

3. Keywords in C

Keywords are reserved words with special meaning.

Examples:

int, float, if, else, while, for, return, break

You cannot use keywords as variable names.

4. Variables

Variables store data.

int age = 20;
float price = 99.5;
char grade = 'A';

Rules:

  • Must start with a letter or _
  • No spaces
  • Case-sensitive

5. Data Types

Data types define what type of data a variable can store.

Data TypeMeaningExample
intInteger10
floatDecimal10.5
doubleLarge decimal99.999
charSingle character‘A’

6. Input and Output

Output

printf("Welcome");

Input

int num;
scanf("%d", &num);

7. Operators

Operators perform actions.

Types of Operators

  1. Arithmetic: + - * / %
  2. Relational: > < >= <= == !=
  3. Logical: && || !
  4. Assignment: = += -=
  5. Increment/Decrement: ++ --

8. Control Statements

Control the flow of the program.

if statement

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

if-else

if(num % 2 == 0)
    printf("Even");
else
    printf("Odd");

9. Loops

Loops repeat code.

for loop

for(int i = 1; i <= 5; i++) {
    printf("%d", i);
}

while loop

while(i <= 5) {
    i++;
}

do-while loop

do {
    i++;
} while(i <= 5);

10. Arrays

Arrays store multiple values.

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

Access value:

marks[0]

11. Strings

Strings are character arrays.

char name[] = "C Language";

Common functions:

  • strlen()
  • strcpy()
  • strcmp()

12. Functions

Functions are blocks of code.

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

Benefits:

  • Code reuse
  • Easy maintenance

13. Pointers

Pointers store memory addresses.

int a = 10;
int *p = &a;

Used for:

  • Dynamic memory
  • Arrays
  • Functions

14. Structures

Structures store different data types together.

struct Student {
    int id;
    char name[20];
};

15. Union

Union is like structure but shares memory.

union Data {
    int i;
    float f;
};

16. File Handling

Used to store data permanently.

FILE *fp;
fp = fopen("data.txt", "w");
fprintf(fp, "Hello");
fclose(fp);

17. Dynamic Memory Allocation

Functions:

  • malloc()
  • calloc()
  • realloc()
  • free()

Example:

int *p = (int*)malloc(5 * sizeof(int));

18. Preprocessor Directives

Used before compilation.

Examples:

#define PI 3.14
#include <stdio.h>

19. Common C Programs

  • Hello World
  • Factorial
  • Fibonacci
  • Prime number
  • Palindrome

20. Advantages of C

  • Fast
  • Portable
  • Low-level access
  • Widely used

21. Disadvantages of C

  • No OOP
  • No automatic memory management
  • Less security

Conclusion

C programming is the base of programming. If you understand C well, learning other languages becomes easy.

👉 Best for students, interviews, and beginners.