The C programming language is a foundational, general-purpose computer programming language created by Dennis Ritchie at Bell Labs in 1972.
Originally developed to write the UNIX operating system, C is widely regarded as the “mother of all programming languages” because it bridges the gap between low-level machine execution and high-level programming abstractions.
1. Basic Structure
#include <stdio.h>
int main() {
printf("Hello, World!");
return 0;
}
2. Variables & Data Types
int age = 25;
float price = 19.99;
double pi = 3.14159;
char grade = 'A';
char name[] = "John";
| Type | Example | Typical Size |
|---|---|---|
int | 10 | 4 bytes |
float | 3.14 | 4 bytes |
double | 3.14159 | 8 bytes |
char | 'A' | 1 byte |
3. Input & Output
printf("Age: %d", age);
scanf("%d", &age);
scanf("%f", &price);
scanf("%c", &grade);
Common format specifiers:
%d int
%f float
%lf double
%c char
%s string
4. Operators
+ - * / % // Arithmetic
== != > < >= <= // Comparison
&& || ! // Logical
++ -- // Increment/Decrement
5. Conditions
if (age >= 18) {
printf("Adult");
} else {
printf("Minor");
}
switch (choice) {
case 1:
printf("One");
break;
default:
printf("Other");
}
6. Loops
for (int i = 0; i < 5; i++) {
printf("%d\n", i);
}
while (condition) {
// code
}
do {
// code
} while (condition);
7. Functions
int add(int a, int b) {
return a + b;
}
int result = add(5, 3);
8. Arrays
int numbers[] = {10, 20, 30, 40};
printf("%d", numbers[0]);
9. Strings
char name[20] = "Codeflare";
printf("%s", name);
Useful header:
#include <string.h>
strlen(name);
strcpy(dest, src);
strcmp(str1, str2);
10. Pointers
int age = 25;
int *ptr = &age;
printf("%d", *ptr);
&→ address of a variable*→ value stored at an address
11. Structures
struct Student {
char name[50];
int age;
};
struct Student student1 = {"John", 20};
12. Dynamic Memory
#include <stdlib.h>
int *ptr = malloc(5 * sizeof(int));
free(ptr);
13. Comments
// Single-line comment
/*
Multi-line comment
*/
14. Compile & Run
gcc program.c -o program
./program
Remember: C programming language is strongly typed, case-sensitive, and uses ; to terminate most statements.

Latest tech news and coding tips.