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.
#include <stdio.h>
int main() {
printf("Hello, World!");
return 0;
} 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 |
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 + - * / % // Arithmetic
== != > < >= <= // Comparison
&& || ! // Logical
++ -- // Increment/Decrement if (age >= 18) {
printf("Adult");
} else {
printf("Minor");
} switch (choice) {
case 1:
printf("One");
break;
default:
printf("Other");
} for (int i = 0; i < 5; i++) {
printf("%d\n", i);
} while (condition) {
// code
} do {
// code
} while (condition); int add(int a, int b) {
return a + b;
}
int result = add(5, 3); int numbers[] = {10, 20, 30, 40};
printf("%d", numbers[0]); char name[20] = "Codeflare";
printf("%s", name); Useful header:
#include <string.h>
strlen(name);
strcpy(dest, src);
strcmp(str1, str2); int age = 25;
int *ptr = &age;
printf("%d", *ptr); & → address of a variable* → value stored at an addressstruct Student {
char name[50];
int age;
};
struct Student student1 = {"John", 20}; #include <stdlib.h>
int *ptr = malloc(5 * sizeof(int));
free(ptr); // Single-line comment
/*
Multi-line comment
*/ gcc program.c -o program
./program Remember: C programming language is strongly typed, case-sensitive, and uses ; to terminate most statements.
Backpressure is a flow-control mechanism that prevents a fast data producer from overwhelming a slower data…
JavaScript collections are data structures used to store, organize, retrieve, and manipulate groups of values. Choosing…
Context poisoning is a technique where an attacker deliberately places misleading, malicious, or irrelevant information into…
React makes building user interfaces easier, but certain errors appear repeatedly, especially when working with…
What Is Homebrew? Homebrew is a package manager for macOS and Linux that makes it easy to…
JavaScript gives you several ways to iterate over an array. Some are better for simple…