C Language Notes
1. C Language kya hai?
C ek general-purpose programming language hai. Iska use system software, operating system, compiler,
embedded systems aur applications banane me hota hai.
2. Basic Structure
#include <stdio.h>
int main() {
printf("Hello World");
return 0;
}
3. Header File
#include <stdio.h>
stdio.h input/output functions ke liye use hota hai, jaise printf() aur scanf().
4. main() Function
Program execution main() function se start hota hai.
5. printf()
Output dikhane ke liye:
printf("Hello");
6. scanf()
User se input lene ke liye:
int a;
scanf("%d", &a);
7. Variables
Data store karne ke liye variable use hota hai.
int age = 20;
float marks = 85.5;
char grade = 'A';
8. Data Types
int: Integer number, float: Decimal number, char: Single character, double: Large decimal number.
9. Operators
+ Addition, - Subtraction, * Multiplication, / Division, % Remainder.
10. Conditional Statement
if (age >= 18) {
printf("Adult");
}
if (marks >= 33) {
printf("Pass");
} else {
printf("Fail");
}
11. Loops
for (int i = 1; i <= 5; i++) {
printf("%d\n", i);
}
int i = 1;
while (i <= 5) {
printf("%d\n", i);
i++;
}
12. Array
Same type ke multiple values store karne ke liye.
int marks[5] = {80, 70, 90, 60, 85};
printf("%d", marks[0]);
13. String
Characters ka collection.
char name[20] = "Rahul";
printf("%s", name);
14. Function
int add(int a, int b) {
return a + b;
}
printf("%d", add(5, 3));
15. Pointer
int a = 10;
int *p = &a;
printf("%d", *p);
16. Structure
struct Student {
int roll;
char name[20];
float marks;
};
17. File Handling
FILE *fp;
fp = fopen("[Link]", "w");
fprintf(fp, "Hello C");
fclose(fp);
18. Important Keywords
int, float, char, if, else, for, while, do, switch, case, break, continue, return, struct, void
19. Simple Program: Add Two Numbers
#include <stdio.h>
int main() {
int a, b, sum;
printf("Enter two numbers: ");
scanf("%d %d", &a, &b);
sum = a + b;
printf("Sum = %d", sum);
return 0;
}
20. Exam Tips
Syntax clearly yaad rakho. Semicolon lagana na bhulo. scanf() me & use karo. Loops aur functions practice karo. Pr