0% found this document useful (0 votes)
37 views3 pages

C Programming Syntax Cheat Sheet

This cheat sheet provides a concise overview of C programming syntax, covering basic structure, data types, variables, input/output functions, operators, control statements, functions, arrays, pointers, structures, and file handling. Each section includes examples to illustrate the concepts. It serves as a quick reference for C programmers.

Uploaded by

rajansah12m
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)
37 views3 pages

C Programming Syntax Cheat Sheet

This cheat sheet provides a concise overview of C programming syntax, covering basic structure, data types, variables, input/output functions, operators, control statements, functions, arrays, pointers, structures, and file handling. Each section includes examples to illustrate the concepts. It serves as a quick reference for C programmers.

Uploaded by

rajansah12m
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 Programming Syntax Cheat Sheet

1. Basic Structure

#include <stdio.h>

int main() {

// Code

return 0;

2. Data Types and Modifiers

int, float, double, char

Modifiers: short, long, signed, unsigned

3. Variables and Constants

int a = 10;

const float PI = 3.14;

4. Input/Output

scanf("%d", &a);

printf("Value: %d", a);

5. Operators

Arithmetic: +, -, *, /, %

Assignment: =, +=, -=, etc.

Relational: ==, !=, >, <, >=, <=

Logical: &&, ||, !

Bitwise: &, |, ^, ~, <<, >>

6. Control Statements
if (condition) { }

else if (condition) { }

else { }

switch (variable) {

case 1: break;

default: break;

while (condition) { }

do { } while (condition);

for (int i = 0; i < 10; i++) { }

7. Functions

return_type function_name(parameters) {

// code

return value;

8. Arrays and Strings

int arr[5] = {1, 2, 3, 4, 5};

char str[] = "Hello";

9. Pointers

int *ptr;

ptr = &a;

10. Structures

struct Person {
char name[20];

int age;

};

11. File Handling

FILE *fp;

fp = fopen("file.txt", "r");

fclose(fp);

You might also like