Programming with C - Notes
1. Introduction to C
Developed by Dennis Ritchie in 1972 at Bell Labs. C is a compiled, procedural language with low-level
memory access. It is widely used for system programming such as operating systems.
2. Structure of a C Program
#include <stdio.h>
int main() {
printf("Hello, World!");
return 0;
3. Data Types
int: Integer
float: Decimal (single precision)
double: Decimal (double precision)
char: Character
4. Variables and Constants
int age = 25;
const float PI = 3.14;
5. Operators
Arithmetic: +, -, *, /, %
Relational: ==, !=, <, >, <=, >=
Logical: &&, ||, !
6. Input and Output
scanf("%d", &age);
printf("Age = %d", age);
Programming with C - Notes
7. Control Statements
If-Else:
if (a > b) {
printf("A is greater");
} else {
printf("B is greater");
Switch:
switch(choice) {
case 1: printf("One"); break;
case 2: printf("Two"); break;
default: printf("Other");
8. Loops
For loop:
for(int i=0; i<5; i++) {
printf("%d", i);
While loop:
while(i<5) {
printf("%d", i);
i++;
9. Functions
int add(int a, int b) {
return a + b;
Programming with C - Notes
10. Arrays
int numbers[5] = {1, 2, 3, 4, 5};
11. Strings
char name[20] = "Esha";
12. Pointers
int x = 10;
int *p = &x;
printf("%d", *p); // Output: 10
13. Structures
struct Person {
char name[50];
int age;
};
14. File Handling
FILE *fp;
fp = fopen("file.txt", "r");
fclose(fp);