๐Ÿ”น Introduction

C is a structured, procedural, and powerful language that lays the foundation for modern programming. To master C, one must understand its core concepts:

  • ๐Ÿ“ฆ Variables

  • ๐Ÿ”„ Loops

  • ๐Ÿ“š Arrays

  • ๐Ÿ› ๏ธ Functions

  • ๐ŸŽฏ Pointers

๐Ÿ‘‰ As the idiom goes: โ€œPractice makes perfect.โ€ The more you practice these concepts, the stronger your programming skills will be.

๐Ÿ“ฆ 1. Variables in C

A variable is a container that stores data values in memory.

๐Ÿ”น Syntax

Code
data_type variable_name = value;

๐Ÿ”น Example

Code
#include <stdio.h>
int main() {

    int age = 20; // Integer variable
    float marks = 88.5; // Floating-point variable
    char grade = 'A'; // Character variable    

    printf("Age: %d\n", age);
    printf("Marks: %.2f\n", marks);
    printf("Grade: %c\n", grade);

    return 0;
}

๐Ÿ‘‰ Output

Age: 20

Marks: 88.50

Grade: A

๐Ÿ”„ 2. Loops in C

Loops allow repetition of code until a condition is met.

๐Ÿ”น Types of Loops

  1. for loop

  2. while loop

  3. do-while loop

Example (Print numbers 1 to 5)

Code
#include <stdio.h>

int main() {
    int i;
    // For Loop

    printf("Using for loop:\n");
    for(i=1; i<=5; i++) {
        printf("%d ", i);
    }
    // While Loop

    printf("\nUsing while loop:\n");

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

    // Do-While Loop

    printf("\nUsing do-while loop:\n");
    i = 1;
    do {

        printf("%d ", i);
        i++;

    } while(i <= 5);
    return 0;
}

๐Ÿ‘‰ Output

Using for loop:

1 2 3 4 5

Using while loop:

1 2 3 4 5

Using do-while loop:

1 2 3 4 5

๐Ÿ“š 3. Arrays in C

An array is a collection of elements of the same data type stored at contiguous memory locations.

๐Ÿ”น Example (Store and display 5 numbers)

Code
#include <stdio.h>

int main() {

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

    printf("Array elements:\n");

    for(i=0; i<5; i++) {
        printf("%d ", arr[i]);
    }
    return 0;
}

๐Ÿ‘‰ Output

Array elements:

10 20 30 40 50

๐Ÿ› ๏ธ 4. Functions in C

A function is a block of code that performs a specific task.

๐Ÿ”น Syntax

Code
return_type function_name(parameters) {
   // code
}

๐Ÿ”น Example (Function to add two numbers)

Code
#include <stdio.h>

// Function declaration

int add(int a, int b);
int main() {

    int x = 5, y = 7, sum;
    sum = add(x, y); // Function call

    printf("Sum = %d", sum);
    return 0;
}

// Function definition

int add(int a, int b) {
    return a + b;
}

๐Ÿ‘‰ Output

Sum = 12

๐ŸŽฏ 5. Pointers in C

A pointer is a variable that stores the memory address of another variable.

๐Ÿ”น Example

Code
#include <stdio.h>

int main() {
    int num = 10;
    int *ptr; // Pointer declaration
    ptr = &num; // Storing address of num

    printf("Value of num = %d\n", num);
    printf("Address of num = %p\n", &num);
    printf("Pointer pointing to = %d\n", *ptr);

    return 0;
}

๐Ÿ‘‰ Sample Output

Value of num = 10

Address of num = 0x7ffee0b3c8

Pointer pointing to = 10

๐ŸŒŸ Conclusion

C Programming is not just theory โ€” it is logic + practice.

  • ๐Ÿ“ฆ Variables help in storing data.

  • ๐Ÿ”„ Loops allow repetition.

  • ๐Ÿ“š Arrays manage collections of data.

  • ๐Ÿ› ๏ธ Functions provide reusability.

  • ๐ŸŽฏ Pointers give memory control.

๐Ÿ‘‰ As the idiom says: โ€œKnowledge without practice is like a lamp without oil.โ€ To master C, practice these concepts daily.

โœจ Once you master these basics, you can move on to structures, file handling, and dynamic memory allocation in C.