C Language Reference
Complete reference for C programming language including syntax, data types, operators, control structures, and standard library functions.
Language Fundamentals
Data Types
Fundamental data types in C programming
intInteger data type
int age = 25;floatFloating-point data type
float price = 19.99;doubleDouble-precision floating-point
double pi = 3.14159;charCharacter data type
char grade = 'A';voidAbsence of type
void function();Operators
C programming operators and their usage
Arithmetic+, -, *, /, %
int result = a + b;Assignment=, +=, -=, *=, /=
a += 5;Comparison==, !=, <, >, <=, >=
if (a == b)Logical&&, ||, !
if (a && b)Bitwise&, |, ^, ~, <<, >>
int result = a & b;Control Structures
Conditional and loop statements
if-elseConditional execution
if (condition) { } else { }switchMulti-way selection
switch (value) { case 1: break; }forFor loop
for (int i = 0; i < 10; i++)whileWhile loop
while (condition) { }do-whileDo-while loop
do { } while (condition);Functions
Function declaration and definition
DeclarationFunction prototype
int add(int a, int b);DefinitionFunction implementation
int add(int a, int b) { return a + b; }ParametersFunction arguments
void print(char* message);ReturnReturn statement
return value;RecursionFunction calling itself
int factorial(int n) { return n * factorial(n-1); }Arrays
Array declaration and manipulation
DeclarationArray declaration
int numbers[10];InitializationArray initialization
int arr[] = {1, 2, 3};AccessArray element access
int value = arr[0];2D ArraysTwo-dimensional arrays
int matrix[3][3];StringsCharacter arrays
char name[50];Pointers
Pointer variables and operations
DeclarationPointer declaration
int *ptr;AddressAddress operator
ptr = &variable;DereferenceValue at address
int value = *ptr;ArithmeticPointer arithmetic
ptr++;DynamicDynamic memory allocation
int *arr = malloc(10 * sizeof(int));Standard Library Functions
stdio.h
printfPrint formatted output
printf("Hello %s", name);scanfRead formatted input
scanf("%d", &number);getcharRead a character
char c = getchar();putcharWrite a character
putchar('A');getsRead a line
gets(buffer);putsWrite a string
puts("Hello");stdlib.h
mallocAllocate memory
int *ptr = malloc(sizeof(int));freeFree allocated memory
free(ptr);callocAllocate and initialize memory
int *arr = calloc(10, sizeof(int));reallocReallocate memory
ptr = realloc(ptr, new_size);exitTerminate program
exit(0);atoiString to integer
int num = atoi("123");string.h
strlenString length
int len = strlen(str);strcpyCopy string
strcpy(dest, src);strcatConcatenate strings
strcat(str1, str2);strcmpCompare strings
if (strcmp(str1, str2) == 0)strchrFind character in string
char *pos = strchr(str, 'a');strstrFind substring
char *pos = strstr(haystack, needle);math.h
sqrtSquare root
double result = sqrt(16);powPower function
double result = pow(2, 3);sinSine function
double result = sin(angle);cosCosine function
double result = cos(angle);absAbsolute value
int result = abs(-5);ceilCeiling function
double result = ceil(4.2);Practice What You Learn
The best way to master C programming is through hands-on practice. Use our online compiler to try out the examples and experiment with the concepts.
Try Our Online C Compiler