Java Cheat Sheet
C Cheat Sheet
1. Basic Syntax
#include <stdio.h>
int main() {
printf("Hello, World!\n");
return 0;
}
2. Data Types
int - Integer (e.g., 10)
float - Floating point (e.g., 10.5)
double - Double precision float
char - Single character (e.g., 'A')
void - No value
3. Operators
+ Addition
- Subtraction
* Multiplication
/ Division
% Modulus
== Equal to
!= Not equal to
>= Greater than or equal to
<= Less than or equal to
4. Control Statements
if (condition) {
// code block
} else {
Java Cheat Sheet
// another code block
}
switch(expression) {
case value1:
// code
break;
default:
// code
}
5. Loops
for (int i = 0; i < 10; i++) {
printf("%d\n", i);
}
while (condition) {
// loop body
}
6. Functions
int add(int a, int b) {
return a + b;
}
7. Pointers
int a = 10;
int *ptr = &a;
printf("%d", *ptr); // Prints value at address stored in ptr
8. File Handling
#include <stdio.h>
Java Cheat Sheet
FILE *fp = fopen("file.txt", "w");
fprintf(fp, "Hello, C");
fclose(fp);
9. Standard Libraries
#include <stdio.h> // Input-output functions
#include <stdlib.h> // Memory allocation, random numbers
#include <math.h> // Mathematical functions
#include <string.h> // String manipulation