C Programming Syntax Cheat Sheet
C Programming Syntax Cheat Sheet
1. Basic Structure
#include <stdio.h>
int main() {
// Code
return 0;
int a = 10;
4. Input/Output
scanf("%d", &a);
5. Operators
Arithmetic: +, -, *, /, %
6. Control Statements
if (condition) { }
else if (condition) { }
else { }
switch (variable) {
case 1: break;
default: break;
while (condition) { }
do { } while (condition);
7. Functions
return_type function_name(parameters) {
// code
return value;
9. Pointers
int *ptr;
ptr = &a;
10. Structures
struct Person {
char name[20];
int age;
};
FILE *fp;
fp = fopen("file.txt", "r");
fclose(fp);