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

C Programming Notes

C is a general-purpose, procedural programming language developed by Dennis Ritchie in 1972, used for various types of software development. The document covers the basic structure of a C program, data types, variables, operators, control statements, loops, functions, arrays, pointers, file handling, dynamic memory allocation, and compilation. It provides examples for each concept to illustrate their usage in programming.

Uploaded by

Mohan
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)
10 views3 pages

C Programming Notes

C is a general-purpose, procedural programming language developed by Dennis Ritchie in 1972, used for various types of software development. The document covers the basic structure of a C program, data types, variables, operators, control statements, loops, functions, arrays, pointers, file handling, dynamic memory allocation, and compilation. It provides examples for each concept to illustrate their usage in programming.

Uploaded by

Mohan
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 Notes

1. Introduction to C
- C is a general-purpose, procedural programming language.
- Developed by Dennis Ritchie in 1972 at Bell Labs.
- Used for system programming, embedded systems, and software development.

2. Basic Structure of a C Program


#include <stdio.h>
int main() {
printf("Hello, World!\n");
return 0;
}

3. Data Types in C
- Basic Types: int, char, float, double
- Derived Types: array, pointer, structure, union
- Void Type: void

4. Variables and Constants


- Declaration: int a; float b; char c;
- Initialization: int a = 10;
- Constants: const int PI = 3.14;

5. Operators in C
- Arithmetic: +, -, *, /, %
- Relational: ==, !=, >, <, >=, <=
- Logical: &&, ||, !
- Bitwise: &, |, ^, ~, <<, >>
- Assignment: =, +=, -=, *=, /=, %=

6. Control Statements
if (condition) {
// Code
} else {
// Code
}
switch (expression) {
case value1:
// Code
break;
default:
// Code
}

7. Loops in C
for (int i = 0; i < 5; i++) {
printf("%d\n", i);
}

8. Functions in C
int add(int a, int b) {
return a + b;
}
int main() {
int sum = add(5, 3);
printf("Sum: %d\n", sum);
return 0;
}

9. Arrays and Pointers


int arr[5] = {1, 2, 3, 4, 5};
printf("%d", arr[0]);

int a = 10;
int *ptr = &a;
printf("%d", *ptr);

10. File Handling


FILE *file = fopen("[Link]", "w");
fprintf(file, "Hello, File!");
fclose(file);

11. Dynamic Memory Allocation


int *ptr = (int*) malloc(5 * sizeof(int));
free(ptr);

12. Compilation and Execution


gcc program.c -o program
./program

You might also like