๐น 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
data_type variable_name = value;๐น Example
#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
for loop
while loop
do-while loop
Example (Print numbers 1 to 5)
#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)
#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
return_type function_name(parameters) {
// code
}๐น Example (Function to add two numbers)
#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
#include <stdio.h>
int main() {
int num = 10;
int *ptr; // Pointer declaration
ptr = # // 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.


Join the conversation! Your thoughts help the community grow.