C Programming Cheat Sheet (Quick Reference Guide)

C programming is one of the most widely used programming languages for learning computer programming fundamentals. It is widely used in system programming, embedded systems development, operating systems, and microcontroller programming.

A C programming cheat sheet provides a quick reference to the most important syntax, operators, functions, and concepts used in C. Instead of searching through long tutorials, students and developers can quickly revise key topics from a single page.

This C language cheat sheet is useful for beginners, engineering students, and developers preparing for technical interviews. You can bookmark this page or download the PDF for quick revision whenever needed.

C Programming Cheat Sheet

Basic Structure of a C Program

Every C program follows a simple structure that includes header files, the main function, and program statements.

#include <stdio.h>

int main() {
    printf("Hello World");
    return 0;
}

Key Components

Component Description
#include Includes header files
main() Entry point of the program
printf() Displays output
return 0 Ends the program

C Data Types Cheat Sheet

Data types specify the type of data that a variable can store.

Data Type Example Description
int int a = 10; Stores integer values
float float x = 3.14; Stores decimal numbers
double double d = 12.567; Higher precision decimal
char char c = 'A'; Stores a single character

Data Type Size (Typical)

Type Size
char 1 byte
int 4 bytes
float 4 bytes
double 8 bytes

Format Specifiers Cheat Sheet

Format specifiers are used with input and output functions such as printf() and scanf().

Specifier Meaning
%d Integer
%f Float
%lf Double
%c Character
%s String

Example:

printf("%d", number);

C Operators Cheat Sheet

Operators perform operations on variables and values.

Arithmetic Operators

Operator Example
+ Addition
- Subtraction
* Multiplication
/ Division
% Modulus

Example

int sum = a + b;

Relational Operators

Used for comparison.

Operator Meaning
==Equal
!=Not equal
>Greater than
<Less than
>=Greater or equal
<=Less or equal

Logical Operators

Operator Meaning
&&Logical AND
||Logical OR
!Logical NOT

Conditional Statements Cheat Sheet

If Statement

if(a > b){
 printf("A is greater");
}

If Else Statement

if(a > b)
 printf("A is greater");
else
 printf("B is greater");

Switch Statement

switch(n){
 case 1:
  printf("One");
  break;

 default:
  printf("Invalid");
}

Loops Cheat Sheet

For Loop

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

While Loop

while(i<5){
 printf("%d",i);
 i++;
}

Do While Loop

do{
 printf("%d",i);
 i++;
}while(i<5);

Arrays Cheat Sheet

int arr[5] = {1,2,3,4,5};
printf("%d", arr[0]);

Array Syntax

datatype array_name[size];

Example

int numbers[10];

Strings in C

In C, strings are stored as character arrays.

char name[20] = "IIES";
printf("%s", name);

Important String Functions

Function Description
strlen()Length of string
strcpy()Copy string
strcat()Concatenate strings
strcmp()Compare strings

Functions Cheat Sheet

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

Function Call

int result = add(5,3);

Pointers Cheat Sheet

int a = 10;
int *p = &a;

printf("%d", *p);
Symbol Meaning
&Address of variable
*Pointer value

Pointers are very important in embedded systems and system programming.

Dynamic Memory Allocation

C allows dynamic memory allocation using functions from stdlib.h.

int *ptr;

ptr = (int*)malloc(5 * sizeof(int));

free(ptr);
Function Purpose
malloc()Allocate memory
calloc()Allocate and initialize memory
realloc()Resize memory
free()Deallocate memory

Structures Cheat Sheet

struct Student{
 int id;
 char name[20];
};

Example

struct Student s1;
s1.id = 1;

Storage Classes Cheat Sheet

Storage Class Description
autoDefault local variable
staticRetains value between function calls
externGlobal variable declaration
registerStored in CPU register

Bitwise Operators Cheat Sheet

Operator Meaning
&AND
|OR
^XOR
~NOT
<<Left shift
>>Right shift

Example

int result = a & b;

File Handling Cheat Sheet

FILE *fp;

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

fprintf(fp,"Hello");

fclose(fp);
Mode Description
rRead
wWrite
aAppend

Important C Header Files

Header File Purpose
stdio.hInput Output
stdlib.hMemory management
string.hString operations
math.hMathematical functions
time.hTime functions

Common Escape Characters

Escape characters are used inside strings.

Escape Character Meaning
\nNew line
\tTab
\Backslash
"Double quote

Example

printf("Hello\nWorld");

C Keywords Cheat Sheet

C language contains reserved keywords that cannot be used as variable names.

Some common C keywords include:

int, char, float, double, if, else, switch, case, break, continue, return, struct, typedef, static, extern

C Programming Interview Topics

Students preparing for programming interviews should revise the following topics:

  • pointers and pointer arithmetic
  • stack vs heap memory
  • dynamic memory allocation
  • recursion
  • arrays and strings
  • structures and unions
  • file handling

These topics are frequently asked in technical interviews and embedded systems programming roles.

Free Download C Programming Cheat Sheet PDF

For quick offline learning, you can download the C Programming Cheat Sheet PDF and use it as a quick reference while coding or preparing for interviews.

Download C Programming Cheat Sheet PDF

Who Should Use This Cheat Sheet

This C programming quick reference guide is useful for:

  • beginners learning C programming
  • engineering students
  • embedded systems learners
  • programmers preparing for interviews
  • developers needing quick syntax reference