0% found this document useful (0 votes)
416 views2 pages

C Language Cheat Sheet

This cheat sheet provides a quick reference for the C programming language, covering variables and data types, input and output functions, conditionals, loops, functions, and arrays. It includes example code snippets for each topic to illustrate usage. This resource is useful for both beginners and experienced programmers looking for a concise guide.

Uploaded by

a4qrmd
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
416 views2 pages

C Language Cheat Sheet

This cheat sheet provides a quick reference for the C programming language, covering variables and data types, input and output functions, conditionals, loops, functions, and arrays. It includes example code snippets for each topic to illustrate usage. This resource is useful for both beginners and experienced programmers looking for a concise guide.

Uploaded by

a4qrmd
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

C Language Cheat Sheet

1. Variables and Data Types


int a = 10; // Integer variable
float b = 20.5; // Floating point variable
char c = 'A'; // Character variable
double d = 30.99; // Double-precision variable

2. Input and Output


printf("Hello, World!\n"); // Output to console
scanf("%d", &a); // Input an integer

3. Conditionals
if (a > 0) {
printf("a is positive\n");
} else {
printf("a is not positive\n");
}

4. Loops
// For loop
for (int i = 0; i < 5; i++) {
printf("%d\n", i);
}
// While loop
int i = 0;
while (i < 5) {
printf("%d\n", i);
i++;
}

5. Functions
int add(int x, int y) {
return x + y;
}

int result = add(5, 3);


printf("%d\n", result);

6. Arrays
int arr[5] = {1, 2, 3, 4, 5};
for (int i = 0; i < 5; i++) {
printf("%d\n", arr[i]);
}

You might also like