C Revision Quick Notes
C Revision Quick Notes
1. Structure of C Program
#include<stdio.h>
void main() {
// your code here
}
3. Operators
- Arithmetic: +, -, *, /, %
- Relational: ==, !=, >, <
- Logical: &&, ||, !
4. Conditional Statements
if (condition) { ... }
else { ... }
switch(choice) {
case 1: ...; break;
default: ...;
}
5. Loops
for (i=0; i<n; i++) {...}
while (condition) {...}
do {...} while (condition);
6. Functions
int add(int a, int b) {
return a + b;
}
7. Arrays
int a[5] = {1, 2, 3, 4, 5};
8. Strings
char name[20];
scanf("%s", name);
String functions: strlen(), strcpy(), strcmp()
9. Pointers
int a = 10, *p;
p = &a;
printf("%d", *p); // outputs 10
10. Structures
struct Student {
int roll;
char name[20];
};