C Cheat Sheet

Only 32 keywords, yet you need a cheat sheet

#Basics

Hello World in C!

#include<stdio.h>

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

Datatypes in C

char
int 
unsigned int
short 
unsigned short
long 
unsigned long

#In and output

Using line breaks

#include <stdio.h>

int main() {
    printf("Got its own line \n");
    printf("Got its own line \n");
}

Printing numbers

#include <stdio.h>

int main() {
    int num = 42069; 
    int num2 = 420.69; 
    printf("Number: %d", num);
    printf("%f", num2);
}
We need to use %d for integers, and %f for doubles.

Reading an integer

#include <stdio.h>

int main() {
    int i; 
    printf("Enter a number: "); 
    scanf("%d", &i); 
    printf("The number: %d\n", i);
}