C Programming

Complete C cheatsheet

Complete C Programming Cheatsheet

A comprehensive reference guide to C programming, covering basic to advanced concepts, syntax, examples, operators, data types, arrays, strings, functions, pointers, structures, unions, memory management, and file handling.

1. Introduction to C

C is a general-purpose, procedural programming language developed by Dennis Ritchie at Bell Laboratories in 1972.

Features of C

Applications of C

File Extensions

ExtensionDescription
.cC source file
.hHeader file
.oObject file
.exeWindows executable

2. Structure of a C Program

#include <stdio.h> int main() { printf("Hello, World!"); return 0; }

Explanation

ComponentDescription
#includeIncludes header files
<stdio.h>Standard input/output header
int main()Main function
{ }Defines a block
printf()Displays output
return 0Indicates successful execution
;Terminates a statement

Compilation Using GCC

gcc program.c -o program ./program

Compile with warnings:

gcc -Wall -Wextra -std=c11 -g program.c -o program

3. Character Set and Tokens

Tokens are the smallest individual elements of a C program.

Types of Tokens

TokenExample
Keywordsint, return, if
Identifierstotal, number
Constants10, 3.14, 'A'
String literals"Hello"
Operators+, -, *
Punctuators;, {}, ()

Rules for Identifiers

  1. Must begin with a letter or underscore.
  2. Cannot begin with a digit.
  3. Cannot contain spaces.
  4. Cannot be a reserved keyword.
  5. C is case-sensitive.
int total; int _number; int marks1; // Invalid identifiers: // int 1marks; // int my marks; // int return;

4. Keywords in C

C11 contains 44 keywords.

CategoryKeywords
Data typesint, char, float, double, void
Decision-makingif, else, switch, case, default
Loopsfor, while, do
Jump statementsbreak, continue, goto, return
Storage classesauto, register, static, extern
Type modifiersshort, long, signed, unsigned
User-defined typesstruct, union, enum, typedef
Type qualifiersconst, volatile, restrict
Other keywordssizeof, _Alignof, _Alignas, _Atomic, _Bool, _Complex, _Generic, _Imaginary, _Noreturn, _Static_assert, _Thread_local

Note: inline is a C99 keyword. bool, true, and false are available through <stdbool.h> in C99 and later.

5. Data Types

Data types specify the kind of data a variable can store.

5.1 Basic Data Types

Data TypeTypical SizeExample
char1 byte'A'
int4 bytes100
float4 bytes10.5f
double8 bytes25.567
voidNo valuevoid

Note: Sizes are implementation-dependent. The sizes above are common on modern systems.

5.2 Type Modifiers

ModifierDescription
signedSupports positive and negative values
unsignedSupports non-negative values
shortShort integer type
longExtended integer type
long longAt least 64-bit integer range
short int a = 10; long int b = 100000; long long int c = 123456789; unsigned int d = 50; signed int e = -20; long double f = 12.345L;

5.3 Derived Data Types

5.4 User-Defined Data Types

6. Variables and Constants

6.1 Variable Declaration

int age; float salary; char grade;

6.2 Variable Initialization

int age = 22; float price = 99.50f; char grade = 'A';

6.3 Multiple Variable Declaration

int a = 10, b = 20, c = 30;

6.4 Constants Using const

const float PI = 3.14159f;

6.5 Constants Using #define

#define MAX 100 #define PI 3.14159

Difference Between const and #define

const#define
Defines a qualified objectDefines a macro
Has a data typeNo data type
Follows normal scope rulesTextual substitution
Cannot be modified through that identifierNo variable to modify

7. Input and Output

Header file: <stdio.h>

7.1 printf()

Displays output.

printf("Hello"); printf("Age = %d", age);

7.2 scanf()

Accepts input.

int age; scanf("%d", &age);

7.3 Common Input/Output Functions

FunctionPurpose
printf()Displays formatted output
scanf()Reads formatted input
getchar()Reads one character
putchar()Displays one character
fgets()Reads a line
puts()Displays a string
fputs()Writes a string
sprintf()Formats output into a string
snprintf()Formats bounded string output
sscanf()Reads formatted data from a string

7.4 Format Specifiers

SpecifierData Type
%dint
%iint
%uunsigned int
%hdshort int
%ldlong int
%lldlong long int
%ffloat in printf; float pointer in scanf
%lfdouble in scanf
%Lflong double
%cchar
%sString
%xHexadecimal
%oOctal
%pPointer address
%zusize_t
%%Percentage symbol

Example

#include <stdio.h> int main() { int age = 22; float marks = 85.5f; char grade = 'A'; printf("Age: %d\n", age); printf("Marks: %.2f\n", marks); printf("Grade: %c\n", grade); return 0; }

8. Escape Sequences

Escape sequences represent special characters.

Escape SequenceMeaning
\nNew line
\tHorizontal tab
\bBackspace
\rCarriage return
\aAlert/bell
\\Backslash
\'Single quotation mark
\"Double quotation mark
\0Null character
\vVertical tab
\fForm feed

Example

printf("Hello\nWorld"); printf("Name:\tUday"); printf("\"C Programming\"");

9. Operators

Operators perform operations on variables and values.

9.1 Arithmetic Operators

OperatorOperationExample
+Additiona + b
-Subtractiona - b
*Multiplicationa * b
/Divisiona / b
%Modulusa % b
int a = 10, b = 3; printf("%d", a + b); // 13 printf("%d", a / b); // 3 printf("%d", a % b); // 1

Integer division discards the fractional part.

9.2 Relational Operators

OperatorMeaning
==Equal to
!=Not equal to
>Greater than
<Less than
>=Greater than or equal
<=Less than or equal

Relational expressions produce 1 for true and 0 for false.

9.3 Logical Operators

OperatorMeaning
&&Logical AND
`
!Logical NOT
int age = 20; if (age >= 18 && age <= 60) { printf("Eligible"); }

9.4 Assignment Operators

OperatorExampleEquivalent
=a = 5Assign
+=a += 5a = a + 5
-=a -= 5a = a - 5
*=a *= 5a = a * 5
/=a /= 5a = a / 5
%=a %= 5a = a % 5
&=a &= 5Bitwise AND assignment
`=``a
^=a ^= 5Bitwise XOR assignment
<<=a <<= 1Left shift assignment
>>=a >>= 1Right shift assignment

9.5 Increment and Decrement Operators

OperatorMeaning
++aPre-increment
a++Post-increment
--aPre-decrement
a--Post-decrement
int a = 5; printf("%d", ++a); // 6 int b = 5; printf("%d", b++); // 5 // b becomes 6

9.6 Bitwise Operators

OperatorOperation
&Bitwise AND
``
^Bitwise XOR
~Bitwise NOT
<<Left shift
>>Right shift
int a = 5; // 0101 int b = 3; // 0011 printf("%d", a & b); // 1 printf("%d", a | b); // 7 printf("%d", a ^ b); // 6 printf("%d", a << 1); // 10 printf("%d", a >> 1); // 2

9.7 Conditional (Ternary) Operator

Syntax:

condition ? expression1 : expression2;

Example:

int a = 10, b = 20; int max = (a > b) ? a : b; printf("%d", max);

9.8 Other Operators

OperatorPurpose
sizeofReturns size in bytes
&Address-of
*Pointer dereference
,Comma operator
.Structure member access
->Structure pointer member access
[]Array subscript
()Function call

10. Operator Precedence

Operators with higher precedence are evaluated first.

PriorityOperatorsAssociativity
1() [] . -> x++ x--Left to right
2++x --x ! ~ sizeof * &Right to left
3* / %Left to right
4+ -Left to right
5<< >>Left to right
6< <= > >=Left to right
7== !=Left to right
8&Left to right
9^Left to right
10``
11&&Left to right
12`
13?:Right to left
14Assignment operatorsRight to left
15,Left to right

Tip: Use parentheses to make complex expressions easier to understand.

11. Type Conversion and Type Casting

Type conversion changes a value from one data type to another.

11.1 Implicit Type Conversion

Automatically performed by the compiler.

int a = 10; float b = 5.5f; float result = a + b;

11.2 Explicit Type Casting

Performed manually by the programmer.

int a = 10, b = 3; float result = (float)a / b; printf("%.2f", result);

Output:

3.33

12. Decision-Making Statements

12.1 if Statement

if (condition) { // Statements }

Example:

int age = 20; if (age >= 18) { printf("Eligible"); }

12.2 if-else Statement

if (condition) { // True block } else { // False block }

12.3 else-if Ladder

int marks = 75; if (marks >= 90) { printf("Grade A"); } else if (marks >= 75) { printf("Grade B"); } else if (marks >= 50) { printf("Grade C"); } else { printf("Fail"); }

12.4 Nested if

if (age >= 18) { if (age <= 60) { printf("Eligible"); } }

12.5 switch Statement

Used for multiple selection conditions.

int choice = 2; switch (choice) { case 1: printf("One"); break; case 2: printf("Two"); break; case 3: printf("Three"); break; default: printf("Invalid choice"); }

Important Points:

13. Looping Statements

Loops execute a block of code repeatedly.

13.1 for Loop

Syntax:

for (initialization; condition; update) { // Statements }

Example:

for (int i = 1; i <= 5; i++) { printf("%d\n", i); }

13.2 while Loop

Condition is checked before execution.

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

13.3 do-while Loop

Executes at least once.

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

13.4 Nested Loop

for (int i = 1; i <= 3; i++) { for (int j = 1; j <= 3; j++) { printf("* "); } printf("\n"); }

13.5 Loop Control Statements

StatementPurpose
breakTerminates the nearest loop or switch
continueSkips the remaining loop body iteration
gotoTransfers control to a labeled statement

14. Arrays

An array stores multiple values of the same data type in contiguous memory.

14.1 One-Dimensional Array

Declaration:

int numbers[5];

Initialization:

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

Accessing elements:

printf("%d", numbers[0]);

Array indexing starts at 0.

14.2 Input and Output of Array

#include <stdio.h> int main() { int a[5]; for (int i = 0; i < 5; i++) { scanf("%d", &a[i]); } for (int i = 0; i < 5; i++) { printf("%d ", a[i]); } return 0; }

14.3 Two-Dimensional Array

Used to represent matrices and tabular data.

Declaration:

int matrix[3][3];

Initialization:

int matrix[2][2] = { {1, 2}, {3, 4} };

Accessing elements:

printf("%d", matrix[0][1]);

14.4 Matrix Traversal

for (int i = 0; i < 2; i++) { for (int j = 0; j < 2; j++) { printf("%d ", matrix[i][j]); } printf("\n"); }

14.5 Three-Dimensional Array

int a[2][3][4];

Used for multidimensional data.

14.6 Important Array Operations

OperationDescription
TraversalVisiting each element
InsertionAdding an element
DeletionRemoving an element
SearchingFinding an element
SortingArranging elements
MergingCombining arrays
ReversingReversing the order

15. Strings

A string is an array of characters terminated by the null character \0.

15.1 String Declaration

char name[20];

15.2 String Initialization

char name[] = "Uday";

Equivalent character array:

char name[] = {'U', 'd', 'a', 'y', '\0'};

15.3 String Input and Output

char name[50]; fgets(name, sizeof(name), stdin); printf("%s", name);

Avoid gets() because it is unsafe and removed from modern C standards.

15.4 String Handling Functions

Header file: <string.h>

FunctionPurpose
strlen()Returns string length
strcpy()Copies a string
strncpy()Copies up to a specified number of characters
strcat()Concatenates strings
strncat()Concatenates a limited number of characters
strcmp()Compares two strings
strncmp()Compares a limited number of characters
strchr()Finds a character
strrchr()Finds the last occurrence of a character
strstr()Finds a substring
strtok()Splits a string into tokens

Example:

#include <stdio.h> #include <string.h> int main() { char str1[50] = "Hello"; char str2[] = " World"; printf("Length: %zu\n", strlen(str1)); strcat(str1, str2); printf("Combined: %s\n", str1); return 0; }

Note: Functions such as strcpy() and strcat() require sufficient destination storage to prevent buffer overflow.

16. Functions

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

16.1 Function Declaration (Prototype)

int add(int, int);

16.2 Function Definition

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

16.3 Function Calling

int result = add(10, 20);

Complete Example

#include <stdio.h> int add(int, int); int main() { int result = add(10, 20); printf("Sum = %d", result); return 0; } int add(int a, int b) { return a + b; }

16.4 Types of Functions

TypeArgumentsReturn Value
1NoNo
2YesNo
3NoYes
4YesYes

16.5 Recursive Function

A function that calls itself.

Example: Factorial.

int factorial(int n) { if (n <= 1) return 1; return n * factorial(n - 1); }

16.6 Call by Value

A copy of the variable is passed.

void change(int x) { x = 100; }

Changes do not affect the original variable.

16.7 Modifying Original Values Through Pointers

C passes arguments by value, but pointers allow a function to modify the caller's objects.

void change(int *x) { *x = 100; } int main() { int a = 10; change(&a); printf("%d", a); // 100 return 0; }

17. Pointers

A pointer is a variable that stores the address of another object or function.

17.1 Pointer Declaration

int *ptr;

17.2 Pointer Initialization

int a = 10; int *ptr = &a;

17.3 Pointer Operators

OperatorPurpose
&Address-of
*Dereferencing

Example:

#include <stdio.h> int main() { int a = 10; int *ptr = &a; printf("Value: %d\n", a); printf("Address: %p\n", (void *)ptr); printf("Pointer value: %d\n", *ptr); return 0; }

17.4 NULL Pointer

A pointer that does not point to a valid object or function.

int *ptr = NULL;

17.5 Void Pointer

A generic object pointer.

int a = 10; void *ptr = &a; printf("%d", *(int *)ptr);

17.6 Pointer to Pointer

int a = 10; int *p = &a; int **pp = &p; printf("%d", **pp);

17.7 Pointer Arithmetic

int a[] = {10, 20, 30}; int *p = a; printf("%d", *p); printf("%d", *(p + 1)); printf("%d", *(p + 2));

Pointer arithmetic is scaled by the size of the pointed-to type.

17.8 Array and Pointer Relationship

int a[3] = {10, 20, 30}; printf("%d", *(a + 1)); printf("%d", a[1]);

Both access the second element.

Important: Arrays and pointers are related, but they are not the same type.

18. Storage Classes

Storage classes determine aspects of variable lifetime, scope, and linkage.

Storage ClassScopeLifetime
autoBlockAutomatic
registerBlockAutomatic
static localBlockEntire program
static file-scopeFileEntire program
externDepends on declarationUsually entire program for the external object

18.1 auto

void test() { auto int x = 10; }

18.2 static

void counter() { static int count = 0; count++; printf("%d\n", count); }

Calling counter() three times prints:

1 2 3

18.3 extern

extern int total;

Declares an object defined elsewhere.

18.4 register

register int i;

A hint to the implementation that a variable may be accessed frequently.

19. Structures

A structure groups variables of different data types under one name.

19.1 Structure Declaration

struct Student { int roll; char name[50]; float marks; };

19.2 Structure Variable

struct Student s1;

19.3 Structure Initialization

struct Student s1 = {101, "Uday", 90.5f};

19.4 Accessing Structure Members

printf("%d", s1.roll); printf("%s", s1.name); printf("%.2f", s1.marks);

19.5 Structure with Pointer

struct Student *ptr = &s1; printf("%d", ptr->roll);

19.6 Array of Structures

struct Student s[3];

19.7 Nested Structure

struct Address { char city[30]; }; struct Student { int roll; struct Address addr; };

20. Unions

A union is a user-defined data type in which all members share the same memory location.

20.1 Union Declaration

union Data { int i; float f; char ch; };

20.2 Union Example

union Data d; d.i = 10; printf("%d", d.i);

Difference Between Structure and Union

StructureUnion
Each member has separate storageMembers share storage
Can store multiple member values simultaneouslyOnly one member value is meaningfully stored at a time
Size includes storage for all members and paddingSize is enough for the largest member plus possible padding
Members have different addressesMembers start at the same address

21. Enumerations (enum)

An enumeration defines named integer constants.

enum Day { MON, TUE, WED, THU, FRI, SAT, SUN };

Example:

enum Day today = WED; printf("%d", today); // 2

Custom Values

enum Status { SUCCESS = 1, FAILURE = 0, PENDING = 5 };

22. typedef

typedef creates an alternative name for an existing type.

typedef unsigned int uint; uint age = 22;

typedef with Structure

typedef struct { int roll; char name[30]; } Student; Student s1;

23. Dynamic Memory Allocation

Header file: <stdlib.h>

Dynamic memory allocation reserves memory during program execution.

23.1 malloc()

Allocates a block of uninitialized memory.

int *ptr = malloc(5 * sizeof *ptr); if (ptr == NULL) { return 1; }

23.2 calloc()

Allocates memory for multiple elements and initializes all bytes to zero.

int *ptr = calloc(5, sizeof *ptr);

23.3 realloc()

Changes the size of an allocated memory block.

int *temp = realloc(ptr, 10 * sizeof *ptr); if (temp != NULL) { ptr = temp; }

23.4 free()

Releases dynamically allocated memory.

free(ptr); ptr = NULL;

Comparison

FunctionPurposeInitial Contents
malloc()Allocates memoryUninitialized
calloc()Allocates multiple elementsAll bytes zero
realloc()Resizes allocationPreserves existing contents up to the smaller size
free()Releases allocationNot applicable

24. File Handling

File handling allows programs to create, read, write, and modify files.

Header file: <stdio.h>

24.1 File Pointer

FILE *fp;

24.2 Opening a File

fp = fopen("data.txt", "r");

24.3 File Opening Modes

ModeDescription
"r"Read existing file
"w"Write; creates or truncates file
"a"Append; creates if needed
"r+"Read and write existing file
"w+"Read and write; truncates or creates
"a+"Read and append; creates if needed
"rb"Read binary file
"wb"Write binary file
"ab"Append binary file
"rb+"Read and write binary file

24.4 Writing to a File

#include <stdio.h> int main() { FILE *fp = fopen("data.txt", "w"); if (fp == NULL) return 1; fprintf(fp, "Hello C Programming"); fclose(fp); return 0; }

24.5 Reading from a File

FILE *fp = fopen("data.txt", "r"); if (fp == NULL) return 1; char str[100]; while (fgets(str, sizeof str, fp) != NULL) { printf("%s", str); } fclose(fp);

24.6 Important File Functions

FunctionPurpose
fopen()Opens a file
fclose()Closes a file
fprintf()Writes formatted data
fscanf()Reads formatted data
fgetc()Reads a character
fputc()Writes a character
fgets()Reads a line
fputs()Writes a string
fread()Reads binary data
fwrite()Writes binary data
fseek()Changes file position
ftell()Returns current file position
rewind()Moves position to beginning
feof()Tests end-of-file indicator
ferror()Tests error indicator
remove()Deletes a file
rename()Renames a file

25. Preprocessor Directives

Preprocessor directives are processed before compilation.

25.1 #include

#include <stdio.h> #include "myheader.h"

25.2 #define

#define PI 3.14159 #define SQUARE(x) ((x) * (x))

25.3 #undef

#undef PI

25.4 Conditional Compilation

#ifdef DEBUG printf("Debug mode"); #endif

Other directives:

#if #elif #else #endif #ifndef

25.5 Header Guards

Prevent repeated inclusion of the same header.

#ifndef MYHEADER_H #define MYHEADER_H void display(void); #endif

26. Command-Line Arguments

Command-line arguments allow users to pass values while executing a program.

#include <stdio.h> int main(int argc, char *argv[]) { printf("Arguments: %d\n", argc); for (int i = 0; i < argc; i++) { printf("%s\n", argv[i]); } return 0; }

27. Important Header Files

Header FilePurpose
<stdio.h>Input and output
<stdlib.h>Memory allocation, conversions, utilities
<string.h>String manipulation
<math.h>Mathematical operations
<ctype.h>Character testing and conversion
<time.h>Date and time
<limits.h>Integer limits
<float.h>Floating-point limits
<stdbool.h>Boolean type and constants
<stdint.h>Fixed-width integer types
<stddef.h>Common definitions such as size_t
<assert.h>Debugging assertions
<errno.h>Error reporting
<signal.h>Signal handling
<locale.h>Localization
<stdarg.h>Variable argument lists

28. Mathematical Functions

Header file: <math.h>

FunctionPurposeExample
sqrt(x)Square rootsqrt(25)
pow(x,y)Powerpow(2,3)
ceil(x)Rounds upwardceil(4.2)
floor(x)Rounds downwardfloor(4.8)
round(x)Rounds to nearest integer valueround(4.5)
fabs(x)Absolute floating-point valuefabs(-5.5)
fmod(x,y)Floating-point remainderfmod(10,3)
sin(x)Sinesin(x)
cos(x)Cosinecos(x)
tan(x)Tangenttan(x)
log(x)Natural logarithmlog(10)
log10(x)Base-10 logarithmlog10(100)
exp(x)Exponentialexp(2)

Trigonometric functions use radians.

29. Character Functions

Header file: <ctype.h>

FunctionPurpose
isalpha()Checks alphabetic character
isdigit()Checks digit
isalnum()Checks alphabet or digit
islower()Checks lowercase
isupper()Checks uppercase
isspace()Checks whitespace
ispunct()Checks punctuation
isprint()Checks printable character
isxdigit()Checks hexadecimal digit
tolower()Converts to lowercase
toupper()Converts to uppercase

Example:

#include <stdio.h> #include <ctype.h> int main() { char ch = 'a'; printf("%c", toupper((unsigned char)ch)); return 0; }

30. Common Programming Problems

These are useful for practical examinations and programming interviews.

ProblemBasic Logic
Even or oddn % 2 == 0
Positive or negativeCompare with zero
Largest of two numbersCompare a and b
Largest of three numbersMultiple comparisons
Swap two numbersTemporary variable
FactorialRepeated multiplication
Prime numberCheck divisors up to square root
Fibonacci seriesAdd previous two terms
Reverse a numberExtract digits using % 10
Palindrome numberCompare with reversed number
Armstrong numberSum each digit raised to number of digits
Sum of digitsRepeated % 10
Count digitsRepeated division by 10
GCDEuclidean algorithm
LCMa / gcd(a,b) * b for nonzero inputs

30.1 Even or Odd

if (n % 2 == 0) printf("Even"); else printf("Odd");

30.2 Factorial

int fact = 1; for (int i = 1; i <= n; i++) { fact *= i; }

30.3 Prime Number

int isPrime = 1; if (n <= 1) { isPrime = 0; } else { for (int i = 2; i <= n / i; i++) { if (n % i == 0) { isPrime = 0; break; } } } if (isPrime) printf("Prime"); else printf("Not Prime");

31. Pattern Programs

31.1 Square Pattern

for (int i = 1; i <= 5; i++) { for (int j = 1; j <= 5; j++) { printf("* "); } printf("\n"); }

Output:

* * * * * * * * * * * * * * * * * * * * * * * * *

31.2 Right Triangle

for (int i = 1; i <= 5; i++) { for (int j = 1; j <= i; j++) { printf("* "); } printf("\n"); }

Output:

* * * * * * * * * * * * * * *

31.3 Inverted Triangle

for (int i = 5; i >= 1; i--) { for (int j = 1; j <= i; j++) { printf("* "); } printf("\n"); }

31.4 Number Triangle

for (int i = 1; i <= 5; i++) { for (int j = 1; j <= i; j++) { printf("%d ", j); } printf("\n"); }

32. Common Errors in C

ErrorMeaning
Syntax errorIncorrect programming syntax
Runtime errorError during program execution
Logical errorProgram executes but produces incorrect output
Linker errorProblem linking program components
Compilation errorCompiler cannot compile the source code

Common Mistakes

// Missing semicolon int a = 10 // Incorrect comparison if (a = 10) // Uninitialized pointer int *ptr; *ptr = 10; // Array out-of-bounds int arr[5]; arr[5] = 10; // Incorrect scanf int age; scanf("%d", age);

Correct Versions

int a = 10; if (a == 10) { printf("Equal"); } int *ptr = NULL; int arr[5]; arr[4] = 10; int age; scanf("%d", &age);

33. Memory Concepts

ConceptDescription
StackCommonly holds automatic local variables and call information
HeapUsed for dynamic memory allocation
Data segmentStores initialized static and global objects
BSS segmentStores zero-initialized and uninitialized static/global objects
Text segmentContains executable instructions

Common Memory Problems

34. Advanced C Concepts

ConceptDescription
Function pointerStores a function's address
Pointer to arrayPoints to an entire array
Array of pointersArray containing pointer elements
Variadic functionAccepts a variable number of arguments
Bit fieldsStructure members with specified bit widths
Flexible array memberArray member with unspecified size at the end of a structure
volatileIndicates an object may change outside normal program flow
constPrevents modification through a particular identifier
restrictProvides an aliasing-related optimization promise
inlineSuggests inline function substitution
_GenericEnables compile-time generic selection
Function recursionFunction calling itself

35. Quick C Syntax Reference

TaskSyntax
Print outputprintf("Hello");
Read integerscanf("%d", &a);
Declare integerint a;
Declare floatfloat a;
Declare characterchar ch;
Declare arrayint arr[10];
Declare stringchar str[50];
Declare pointerint *ptr;
Declare functionint add(int a, int b);
Declare structurestruct Student s;
Declare unionunion Data d;
Declare enumenum Day d;
Allocate memorymalloc()
Release memoryfree()
Open filefopen()
Close filefclose()
Calculate sizesizeof()
Return from functionreturn value;
Include library#include <stdio.h>