0% found this document useful (0 votes)
3 views33 pages

C Programming Notes

The document provides detailed notes on the principles of programming using the C language, covering topics such as the history of C, program structure, functions, and language fundamentals. It includes sections on operators, control structures, arithmetic problems, and functions, along with examples and common mistakes. The notes emphasize the importance of C in system-level programming and its relevance in modern programming languages.

Uploaded by

rg7710391
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)
3 views33 pages

C Programming Notes

The document provides detailed notes on the principles of programming using the C language, covering topics such as the history of C, program structure, functions, and language fundamentals. It includes sections on operators, control structures, arithmetic problems, and functions, along with examples and common mistakes. The notes emphasize the importance of C in system-level programming and its relevance in modern programming languages.

Uploaded by

rg7710391
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

Contents

Principles of Programming using ‘C’ – I 2


(Detailed Hinglish Notes) . . . . . . . . . . . . . . . . . . . . . . . . . 2
SECTION 1: INTRODUCTION . . . . . . . . . . . . . . . . . . . . . . . . . 2
1.1 History of C Language . . . . . . . . . . . . . . . . . . . . . . . . . 2
1.2 Structure of a C Program . . . . . . . . . . . . . . . . . . . . . . . 2
1.3 Function as Building Blocks . . . . . . . . . . . . . . . . . . . . . . 3
1.4 Language Fundamentals . . . . . . . . . . . . . . . . . . . . . . . . 4
Section 1 Summary (Quick Recap) . . . . . . . . . . . . . . . . . . . . 6
SECTION 2: OPERATORS . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
2.1 Types of Operators . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
2.2 Precedence and Associativity . . . . . . . . . . . . . . . . . . . . . 8
2.3 Expressions and Statements . . . . . . . . . . . . . . . . . . . . . . 8
2.4 Console Based I/O Functions . . . . . . . . . . . . . . . . . . . . . 9
2.5 Header Files aur Preprocessor Directives . . . . . . . . . . . . . . 10
Section 2 Summary (Quick Recap) . . . . . . . . . . . . . . . . . . . . 11
SECTION 3: CONTROL STRUCTURES . . . . . . . . . . . . . . . . . . . . 11
3.1 Decision Making Structures . . . . . . . . . . . . . . . . . . . . . . 11
3.2 Loop Control Structures . . . . . . . . . . . . . . . . . . . . . . . . 13
3.3 Other Statements . . . . . . . . . . . . . . . . . . . . . . . . . . . 15
Section 3 Summary (Quick Recap) . . . . . . . . . . . . . . . . . . . . 16
SECTION 4: SIMPLE ARITHMETIC PROBLEMS . . . . . . . . . . . . . . . 16
4.1 Addition of Two Numbers . . . . . . . . . . . . . . . . . . . . . . . 16
4.2 Multiplication of Integers . . . . . . . . . . . . . . . . . . . . . . . 17
4.3 Check if Number is Negative / Positive / Zero . . . . . . . . . . . . 17
4.4 Check if Number is Even or Odd . . . . . . . . . . . . . . . . . . . 17
4.5 Maximum of Two Numbers . . . . . . . . . . . . . . . . . . . . . . 18
4.6 Sum of First N Natural Numbers . . . . . . . . . . . . . . . . . . . 18
4.7 Sum of Given N Numbers (User Input) . . . . . . . . . . . . . . . . 19
4.8 Integer Division . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19
4.9 Digit Reversing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20
4.10 Table Generation for N . . . . . . . . . . . . . . . . . . . . . . . . 20
4.11 Factorial of a Number . . . . . . . . . . . . . . . . . . . . . . . . 21
4.12 Sine Series (Taylor Series) . . . . . . . . . . . . . . . . . . . . . . 21
4.13 Cosine Series (Taylor Series) . . . . . . . . . . . . . . . . . . . . . 22
4.14 Pascal’s Triangle . . . . . . . . . . . . . . . . . . . . . . . . . . . 22
4.15 Prime Number Check . . . . . . . . . . . . . . . . . . . . . . . . . 23
4.16 Factors of a Number . . . . . . . . . . . . . . . . . . . . . . . . . 24
4.17 Perfect Number . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24
4.18 GCD (Greatest Common Divisor) of Two Numbers . . . . . . . . . 25
4.19 Swapping of Two Numbers . . . . . . . . . . . . . . . . . . . . . . 25
Section 4 Summary (Quick Recap) . . . . . . . . . . . . . . . . . . . . 26
SECTION 5: FUNCTIONS . . . . . . . . . . . . . . . . . . . . . . . . . . . 26
5.1 Basic Types of Functions . . . . . . . . . . . . . . . . . . . . . . . . 26
5.2 Function Declaration, Definition aur Call . . . . . . . . . . . . . . . 27
5.3 Types of Functions (Based on Parameters and Return Value) . . . . 27
5.4 Parameter Passing: Call by Value vs Call by Reference . . . . . . . 28

1
5.5 Scope of Variables . . . . . . . . . . . . . . . . . . . . . . . . . . . 29
5.6 Storage Classes . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30
5.7 Recursion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31
Section 5 Summary (Quick Recap) . . . . . . . . . . . . . . . . . . . . 32
FINAL QUICK REVISION (Poore Syllabus Ka Recap) . . . . . . . . . . . . . 32

Principles of Programming using ‘C’ – I


(Detailed Hinglish Notes)

SECTION 1: INTRODUCTION
1.1 History of C Language

C language ko Dennis Ritchie ne 1972 mein Bell Labs (AT&T) mein develop kiya
tha. C se pehle B language thi (jo Ken Thompson ne banayi thi), aur B se pehle BCPL
language thi. C ko is liye banaya gaya tha kyunki UNIX operating system ko likhne
ke liye ek powerful, low-level jaisi flexibility wali, lekin high-level jaisi readability wali
language chahiye thi.
Kyun important hai C: - C ek middle-level language hai — matlab ye hardware
ke close bhi kaam kar sakti hai (jaise assembly) aur high-level abstraction bhi deti
hai (jaise loops, functions). - Aaj bhi Operating Systems (Linux kernel), Embedded
Systems, Compilers, Database engines (jaise MySQL) C mein hi likhe jaate hain. - C
ne hi aage chal kar C++, Java, C#, jaise languages ko syntax aur concepts diye.
Common confusion: Log sochte hain C “purani” hone ki wajah se “useless” hai —
lekin aisa nahi hai. C aaj bhi system-level programming ki backbone hai, isliye ise
seekhna zaroori hai.

1.2 Structure of a C Program

Har C program ek fixed structure follow karta hai. Ye structure samajhna bahut za-
roori hai kyunki agar aap iska order galat kar doge to compiler error dega.
1. Documentation / Comments (optional - program kya karta hai, yeh batane ke liye)
2. Preprocessor Directives (#include, #define)
3. Global Declarations (global variables, function prototypes)
4. main() function (program yahin se start hota hai)
{
Local variable declarations
Statements / Instructions
return statement
}
5. User-defined functions (agar koi hai to)

2
Example:
/* Yeh program 2 numbers ka sum print karta hai */ // 1. Documentation

#include <stdio.h> // 2. Preprocessor directive - stdio.h header include ho ra

int add(int, int); // 3. Function prototype (global declaration)

int main() // 4. main function - program ka entry point


{
int a = 5, b = 10; // local variable declaration
int sum;

sum = add(a, b); // function call


printf("Sum = %d", sum); // output print karna

return 0; // program successfully terminate hua


}

int add(int x, int y) // 5. user-defined function ki definition


{
return x + y;
}

Output:
Sum = 15
Explanation line by line: - #include <stdio.h> compiler ko batata hai ki printf
jaisi standard functions ki definitions is header file mein hain, unhe program mein
“include” (copy-paste jaisa) kar do. - int main() woh function hai jahan se program
execution start hota hai. Har C program mein exactly ek main() hona zaroori hai. -
Curly braces { } function ki body (block) ko define karte hain. - return 0; operating
system ko batata hai ki program successfully complete hua (0 = no error).
Common Mistake: Beginners main() ke andar semicolon (;) laga dete hain — jaise
int main(); — yeh galat hai, isse function ka definition alag ho jaata hai aur “unde-
fined reference” error aata hai.

1.3 Function as Building Blocks

C programming mein program ko chhote-chhote functions mein todna best practice


hai. Har function ek specific kaam karta hai — jaise ek building blocks (LEGO blocks)
hote hain, waise hi functions ko jod kar bada program banaya jaata hai.
Fayde: 1. Modularity – code chhote parts mein divide ho jaata hai, samajhna aasan
hota hai. 2. Reusability – ek function ko baar baar call kar sakte hain, dubara likhna
nahi padta. 3. Debugging aasan – agar error hai to sirf uss function ko dekhna
padta hai, poora program nahi.

3
#include <stdio.h>

void greet() { // ek chhota building block function


printf("Hello Student!\n");
}

int main() {
greet(); // is function ko call kiya
greet(); // dobara call kiya - reusability
return 0;
}

Output:
Hello Student!
Hello Student!

1.4 Language Fundamentals

(a) Character Set C compiler jin characters ko samajhta hai unka set “character
set” kehlata hai: - Alphabets: A-Z, a-z - Digits: 0-9 - Special symbols: + - * / =
( ) { } [ ] , ; : ' " # & ^ ! ~ | \ < > . ? _ % @ - White spaces: space, tab,
newline

(b) C Tokens Program ki sabse chhoti individual unit ko token kehte hain. C com-
piler program ko tokens mein tod kar hi samajhta hai. Tokens 6 types ke hote hain:

Token Type Example


Keywords int, for, while
Identifiers sum, myVariable
Constants 10, 3.14, 'A'
Strings "Hello"
Operators +, -, *, =
Special Symbols {}, (), ;

Example: int sum = 5 + 3; Yahan tokens hain: int (keyword), sum (identifier), =
(operator), 5 (constant), + (operator), 3 (constant), ; (special symbol).

(c) Keywords Keywords woh reserved words hain jinka pehle se hi ek fixed mean-
ing C compiler mein defined hai. Inhe variable ya function ka naam nahi bana sakte.
Total 32 keywords C mein hote hain, jaise: int, float, char, double, if, else,
for, while, do, switch, case, break, continue, return, void, struct, union,
typedef, static, extern, const, sizeof, goto, enum etc.

4
Common Mistake: int int = 5; — yeh galat hai kyunki int ek keyword hai, ise
variable name nahi bana sakte.

(d) Identifiers Identifiers woh naam hain jo hum khud apne variables, functions,
arrays, etc. ko dete hain.
Rules for naming identifiers: 1. Sirf letters (A-Z, a-z), digits (0-9), aur underscore
(_) use kar sakte hain. 2. Pehla character letter ya underscore hona chahiye, digit
nahi ho sakta. 3. Keywords ko identifier nahi bana sakte. 4. C case-sensitive hai —
matlab Sum aur sum do alag identifiers hain. 5. Koi space ya special symbol (jaise @, #)
allowed nahi.
int roll_no; // valid
int _marks; // valid
int 2ndYear; // INVALID - digit se start nahi ho sakta
int total-marks; // INVALID - hyphen allowed nahi

(e) Variables Variable ek naam diya gaya memory location hai jiski value pro-
gram run hone ke dauraan change ho sakti hai.
int age; // declaration - compiler ko batate hain ki 'age' naam ka int type var
age = 20; // assignment - value store ki
int marks = 90; // declaration + initialization ek saath

Concept samjho: Jab hum int age; likhte hain, to compiler memory mein kahin ek
jagah (address) reserve kar deta hai jiska naam “age” hota hai. Jab hum age = 20
karte hain to us memory location mein value 20 store ho jaati hai.

(f) Constants Constants woh values hain jo program ke execution ke dauraan


change nahi hoti.
#define PI 3.14159 // symbolic constant (preprocessor ke through)
const int MAX = 100; // const keyword se banaya gaya constant

int main() {
printf("%f", PI);
// PI = 3.5; // ERROR - constant ki value change nahi kar sakte
}

Types of constants: Integer constant (10), Real/Float constant (3.14), Character


constant ('A'), String constant ("Hello").

(g) Data Types Data type batata hai ki variable kis tarah ka data store karega aur
kitni memory use karega.

Data Type Size (typical) Format Specifier Example


int 4 bytes %d int a = 10;
float 4 bytes %f float b = 5.5;

5
Data Type Size (typical) Format Specifier Example
double 8 bytes %lf double c = 5.55555;
char 1 byte %c char d = 'A';

#include <stdio.h>
int main() {
int a = 10;
float b = 5.5;
char c = 'A';
double d = 99.999;

printf("Int: %d\n", a);


printf("Float: %f\n", b);
printf("Char: %c\n", c);
printf("Double: %lf\n", d);
return 0;
}

Output:
Int: 10
Float: 5.500000
Char: A
Double: 99.999000
Common Mistake: float ke liye %lf aur printf mein use karna technically chalta
hai (compiler warning de sakta hai), lekin scanf mein float ke liye hamesha %f hi use
karo aur double ke liye %lf — yahan galti hone par garbage value aati hai.

(h) Comments Comments woh lines hain jo compiler ignore kar deta hai — ye sirf
programmer ke samajhne ke liye hote hain.
// Yeh single-line comment hai

/* Yeh
multi-line
comment hai */

Section 1 Summary (Quick Recap)

• C 1972 mein Dennis Ritchie ne banayi, UNIX ke liye.


• Har program #include se start hota hai, main() function se execute hota hai.
• Functions program ko chhote reusable blocks mein todte hain.
• Tokens = program ki smallest units (keywords, identifiers, constants, strings,
operators, symbols).

6
• Keywords fixed hote hain (32), identifiers hum khud banate hain (kuch rules ke
sath).
• Variables value store karte hain jo change ho sakti hai; constants change nahi
hoti.
• Data types batate hain memory size aur value ka type (int, float, char, double).

SECTION 2: OPERATORS
2.1 Types of Operators

Operator ek symbol hota hai jo compiler ko batata hai ki kisi variable/constant par
konsa mathematical ya logical operation perform karna hai.

Type Operators Kaam


Arithmetic + - * / % Basic math operations
Relational > < >= <= == != Comparison (true/false result)
Logical && \|\| ! Multiple conditions combine karna
Assignment = += -= *= /= Value assign karna
Increment/Decrement ++ -- Value ko 1 se badhana/ghatana
Bitwise & \| ^ ~ << >> Bit-level operations
Conditional (Ternary) ? : Short if-else

#include <stdio.h>
int main() {
int a = 10, b = 3;

printf("Addition: %d\n", a + b); // Arithmetic


printf("Is a>b: %d\n", a > b); // Relational (1 = true)
printf("AND: %d\n", (a>5 && b>1)); // Logical
printf("Modulus: %d\n", a % b); // Arithmetic - remainder
a += 5; // Assignment operator - a = a+5
printf("a after += : %d\n", a);
return 0;
}

Output:
Addition: 13
Is a>b: 1
AND: 1
Modulus: 1
a after += : 15
Modulus (%) ka concept: Yeh sirf integers ke sath kaam karta hai aur division ke
baad remainder deta hai. Jaise 10 % 3 = 1 (kyunki 10, 3 se 3 baar divide hota hai
aur 1 bacha reh jaata hai). Yeh operator odd/even check karne mein bahut use hota
hai.

7
Common Mistake: Beginners = (assignment) aur == (comparison) mein confuse ho
jaate hain.
if (a = 5) // GALAT (logical mistake) - yeh a mein 5 assign kar dega, aur condition h
if (a == 5) // SAHI - yeh check karega ki a ki value 5 hai ya nahi

2.2 Precedence and Associativity

Precedence batata hai ki multiple operators ek expression mein ho to konsa pehle


evaluate hoga. Associativity batati hai ki same precedence wale operators ka evalu-
ation order left-to-right hoga ya right-to-left.
int result = 10 + 5 * 2; // * ki precedence + se zyada hai
// isliye pehle 5*2=10 hoga, phir 10+10=20 hoga
printf("%d", result); // Output: 20

Common precedence order (high to low): () > * / % > + - > relational > && ||
> =
Example jahan associativity matter karti hai:
int a = 10 - 5 - 2; // subtraction left-to-right associative hai
// (10-5)-2 = 3, na ki 10-(5-2)=7
printf("%d", a); // Output: 3

Common Mistake: Bina brackets use kiye complex expressions likhna, jaise a + b
* c / d - e. Agar confusion ho to hamesha () use karo taaki apni intended order
clearly mile — code readable bhi hota hai.

2.3 Expressions and Statements

Expression ek combination hai variables, constants aur operators ka jo ek value


produce karta hai. Jaise a + b, x * y - 2.
Statement ek complete instruction hai jo compiler ko execute karne ko kehti hai.
Statement ke end mein semicolon (;) lagta hai.
Types of statements: 1. Expression statement - a = b + c; 2. Compound
statement (block) - { int a; a=5; } - multiple statements ek {} ke andar 3. Control
statements - if, for, while etc. 4. Null statement - sirf ; (kuch bhi nahi karta,
kabhi-kabhi loops mein use hota hai)
int a, b, c;
a = 5; // expression statement
b = 10;
c = a + b; // expression statement - "a+b" ek expression hai
{ // compound statement start
int temp = c;

8
c = temp * 2;
} // compound statement end

2.4 Console Based I/O Functions

C mein input lena aur output dikhana stdio.h header file ke functions se hota hai.

printf("Value = %d", 10); // format specifier %d integer ke liye

printf() - Output ke liye

int age;
printf("Enter age: ");
scanf("%d", &age); // '&' address-of operator hai - variable ka memory address deta
printf("Your age is %d", age);

scanf() - Input lene ke liye & kyun zaroori hai scanf mein? scanf ko pata hona
chahiye ki value kahan store karni hai - isliye variable ka address (&age) diya jaata
hai, sirf value (age) nahi. Yeh ek sabse common beginner mistake hai - & bhool jaana.

char ch;
ch = getch(); // conio.h header chahiye (Turbo C / Windows compilers mein)

getch() - Ek character read karta hai, screen par show NAHI karta (echo nahi
hota), aur Enter dabane ki zaroorat nahi

char ch;
ch = getchar(); // stdio.h se aata hai, standard/portable hai

getchar() - Ek character read karta hai standard input se, screen par show
hota hai, Enter dabana padta hai

putchar('A'); // Output: A

putchar() - Ek character print karta hai Full example:


#include <stdio.h>
int main() {
char ch;
printf("Enter a character: ");
ch = getchar(); // input le raha hai

9
printf("You entered: ");
putchar(ch); // output kar raha hai
return 0;
}

Output (agar user ‘X’ type kare):


Enter a character: X
You entered: X
Common Mistake: getch() standard C mein nahi hai (yeh conio.h se aata hai jo sirf
Turbo C/Windows compilers mein available hai) - Linux/GCC mein isse error aa sakta
hai. getchar() hamesha portable hai, isliye exams/interviews mein getchar() prefer
karo agar cross-platform code chahiye.

2.5 Header Files aur Preprocessor Directives

Header file ek file hoti hai jisme pehle se likhe hue functions ki declarations hoti hain
(jaise printf, scanf ki declarations stdio.h mein hain). Header file include karne se
hum bina khud function likhe unhe use kar sakte hain.
Preprocessor directives woh instructions hain jo actual compilation shuru hone se
pehle process hoti hain. Ye # symbol se start hoti hain.

#include Kisi header file ko program mein “copy” karta hai.


#include <stdio.h> // angle brackets <> - system/standard header files ke liye
#include "myheader.h" // double quotes "" - apni khud ki banayi header files ke liye

#define Ek macro (symbolic constant) define karta hai - compile hone se pehle hi
is naam ki jagah value put ho jaati hai.
#include <stdio.h>
#define PI 3.14159 // PI naam ka macro, value 3.14159
#define SQUARE(x) ((x)*(x)) // function-like macro

int main() {
float area, radius = 5;
area = PI * radius * radius;
printf("Area = %f\n", area);
printf("Square of 4 = %d\n", SQUARE(4));
return 0;
}

Output:
Area = 78.539750
Square of 4 = 16

10
Concept samjho: #define mein jo bhi likha hota hai, compilation se pehle hi pre-
processor us naam ko literal text se replace kar deta hai - jaise “Find & Replace”.
Isliye PI ki jagah 3.14159 seedha code mein chala jaata hai compile hone se pehle hi.
Common Mistake: Macro mein brackets na lagana. #define SQUARE(x) x*x likhoge
to SQUARE(2+3) ka result 2+3*2+3 = 11 aayega (galat), jabki ((x)*(x)) likhne se
((2+3)*(2+3)) = 25 sahi aayega. Isliye macros mein hamesha extra brackets lagao.

Section 2 Summary (Quick Recap)

• Operators: Arithmetic, Relational, Logical, Assignment, Increment/Decrement,


Bitwise, Ternary.
• Precedence decide karta hai kaunsa operator pehle evaluate hoga; Associativity
direction batati hai.
• Expression = value produce karta hai; Statement = complete executable instruc-
tion.
• printf/scanf I/O ke liye; scanf mein & zaroori hai address dene ke liye.
• getch() non-standard (conio.h), getchar() standard aur portable (stdio.h).
• #include header file jodta hai; #define macro/constant banata hai (compile se
pehle text-replace hota hai).

SECTION 3: CONTROL STRUCTURES


Control structures woh statements hain jo program ke flow (kis order mein state-
ments execute honge) ko control karte hain. Normally program top-to-bottom execute
hota hai, lekin control structures se hum ise change kar sakte hain.

3.1 Decision Making Structures

(a) if statement Agar condition true hai to hi block execute hoga.


#include <stdio.h>
int main() {
int marks = 85;
if (marks > 40) {
printf("Pass\n");
}
return 0;
}

Output: Pass

(b) if-else statement Condition true ho to if block, false ho to else block execute
hota hai.

11
#include <stdio.h>
int main() {
int num = 7;
if (num % 2 == 0) {
printf("Even\n");
} else {
printf("Odd\n");
}
return 0;
}

Output: Odd

(c) Nested if-else if ya else ke andar dubara if-else use karna. Jab multiple
conditions check karni ho.
#include <stdio.h>
int main() {
int marks = 75;
if (marks >= 90) {
printf("Grade A\n");
} else {
if (marks >= 75) {
printf("Grade B\n");
} else {
printf("Grade C\n");
}
}
return 0;
}

Output: Grade B
Concept samjho: Nested if-else tab use karte hain jab conditions hierarchi-
cal/dependent hoti hain — jaise pehle check karo marks 90+ hain ya nahi, agar
nahi to phir check karo 75+ hain ya nahi. Iski jagah else if ladder bhi use kar sakte
hain jo padhne mein aasan hota hai:
if (marks >= 90) printf("Grade A\n");
else if (marks >= 75) printf("Grade B\n");
else printf("Grade C\n");

(d) switch statement Jab ek hi variable ki multiple specific values check karni ho,
tab switch use karte hain (bahut saari if-else if ki jagah).
#include <stdio.h>
int main() {
int day = 3;
switch (day) {

12
case 1: printf("Monday\n"); break;
case 2: printf("Tuesday\n"); break;
case 3: printf("Wednesday\n"); break;
default: printf("Invalid day\n");
}
return 0;
}

Output: Wednesday
Common Mistake: break; bhool jaana. Agar break nahi lagate to control agle case
mein bhi chala jaata hai (isse “fall-through” kehte hain), jo galat output de sakta
hai:
switch(2) {
case 1: printf("One\n");
case 2: printf("Two\n"); // yahan se print hoga
case 3: printf("Three\n"); // break na hone ki wajah se yeh bhi print ho jaayega!
}
// Output: Two \n Three (galat agar sirf "Two" chahiye tha)

3.2 Loop Control Structures

Loop ek block of code ko baar baar execute karne ke liye use hota hai jab tak ek
condition true rehti hai.

(a) while loop Condition pehle check hoti hai, phir body execute hoti hai (entry-
controlled loop).
#include <stdio.h>
int main() {
int i = 1;
while (i <= 5) {
printf("%d ", i);
i++; // increment - warna infinite loop ho jaayega
}
return 0;
}

Output: 1 2 3 4 5

(b) do-while loop Body pehle ek baar execute hoti hai, uske baad condition check
hoti hai (exit-controlled loop). Isliye body kam se kam ek baar zaroor chalti hai,
chahe condition false ho.
#include <stdio.h>
int main() {

13
int i = 10;
do {
printf("%d ", i);
i++;
} while (i <= 5); // condition false hai, phir bhi 1 baar chala
return 0;
}

Output: 10 (condition false hone ke bawajood ek baar chala kyunki do-while pehle
execute karta hai, phir check karta hai)

(c) for loop Jab humein pata ho ki loop kitni baar chalana hai, tab for loop best
hai — initialization, condition, aur increment/decrement ek hi line mein hoti hai.
#include <stdio.h>
int main() {
for (int i = 1; i <= 5; i++) { // (initialization; condition; increment)
printf("%d ", i);
}
return 0;
}

Output: 1 2 3 4 5

(d) Nested for loop For loop ke andar for loop — patterns print karne, matrix op-
erations mein bahut use hota hai.
#include <stdio.h>
int main() {
for (int i = 1; i <= 3; i++) { // outer loop - rows
for (int j = 1; j <= i; j++) { // inner loop - columns
printf("* ");
}
printf("\n");
}
return 0;
}

Output:
*
* *
* * *
Concept samjho: Outer loop ek baar chalta hai to inner loop poora chal kar khatam
hota hai, tab jaake outer loop agli value par jaata hai. Yeh samajhna pattern printing
ke liye bahut zaroori hai.
Common Mistake: for loop mein semicolon galat jagah laga dena:

14
for (int i=0; i<5; i++); // GALAT - yahan semicolon se loop khali body ke sath khatam
{
printf("%d", i); // yeh loop se bahar hai, sirf ek baar chalega
}

3.3 Other Statements

break Loop ya switch se turant bahar nikal jaata hai.


for (int i = 1; i <= 10; i++) {
if (i == 5) break; // jaise hi i=5 hota hai, loop rukk jaata hai
printf("%d ", i);
}
// Output: 1 2 3 4

continue Current iteration ko skip kar deta hai aur agli iteration par chala jaata hai
(loop khatam nahi hota).
for (int i = 1; i <= 5; i++) {
if (i == 3) continue; // 3 ko skip kar dega
printf("%d ", i);
}
// Output: 1 2 4 5

goto Program control ko kisi specific labeled line par le jaata hai. Modern program-
ming mein iska use avoid kiya jaata hai kyunki yeh code ko samajhna mushkil bana
deta hai (“spaghetti code”).
#include <stdio.h>
int main() {
int i = 1;
start: // label
if (i <= 5) {
printf("%d ", i);
i++;
goto start; // control 'start' label par wapas jaata hai
}
return 0;
}

Output: 1 2 3 4 5

exit() Program ko turant band kar deta hai, chahe woh kahin bhi ho (loop ke andar,
function ke andar). Isko use karne ke liye stdlib.h include karna padta hai.

15
#include <stdio.h>
#include <stdlib.h>
int main() {
printf("Before exit\n");
exit(0); // program yahin khatam ho jaayega
printf("After exit\n"); // yeh line kabhi execute nahi hogi
return 0;
}

Output: Before exit


break vs exit() mein farak: break sirf current loop/switch se bahar nikalta hai,
program chalta rehta hai. exit() poora program hi khatam kar deta hai.

Section 3 Summary (Quick Recap)

• if, if-else, nested if-else: condition ke basis par decision lene ke liye.
• switch: ek variable ki multiple fixed values check karne ke liye; break na
bhoolna.
• while: entry-controlled loop (pehle check, phir execute).
• do-while: exit-controlled loop (pehle execute, phir check) - kam se kam 1 baar
chalta hai.
• for: jab iterations ki count pehle se pata ho.
• Nested loops: patterns aur matrix ke liye - outer loop ek baar, inner loop poora
chalta hai.
• break: loop se bahar nikalna; continue: current iteration skip karna; goto: label
par jump; exit(): poora program terminate.

SECTION 4: SIMPLE ARITHMETIC PROBLEMS


Is section mein hum har problem ka logic samjhenge aur uska complete working
C program dekhenge sample input/output ke sath.

4.1 Addition of Two Numbers

Logic: Do numbers input lo, + operator se add karo, print karo.


#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);

16
return 0;
}

Input: 5 10 → Output: Sum = 15

4.2 Multiplication of Integers

#include <stdio.h>
int main() {
int a, b, product;
printf("Enter two numbers: ");
scanf("%d %d", &a, &b);
product = a * b;
printf("Product = %d", product);
return 0;
}

Input: 4 5 → Output: Product = 20

4.3 Check if Number is Negative / Positive / Zero

Logic: if-else se number ko 0 se compare karo.


#include <stdio.h>
int main() {
int num;
printf("Enter a number: ");
scanf("%d", &num);
if (num > 0)
printf("Positive\n");
else if (num < 0)
printf("Negative\n");
else
printf("Zero\n");
return 0;
}

Input: -7 → Output: Negative

4.4 Check if Number is Even or Odd

Logic: Number ko 2 se modulus (%) karo. Agar remainder 0 hai to even, warna odd.

17
#include <stdio.h>
int main() {
int num;
printf("Enter a number: ");
scanf("%d", &num);
if (num % 2 == 0)
printf("Even\n");
else
printf("Odd\n");
return 0;
}

Input: 13 → Output: Odd

4.5 Maximum of Two Numbers

#include <stdio.h>
int main() {
int a, b;
printf("Enter two numbers: ");
scanf("%d %d", &a, &b);
if (a > b)
printf("Maximum = %d", a);
else
printf("Maximum = %d", b);
return 0;
}

Input: 8 15 → Output: Maximum = 15


(Ternary operator se ek line mein bhi likh sakte hain: int max = (a > b) ? a : b;)

4.6 Sum of First N Natural Numbers

Logic: Loop chalao 1 se N tak, har number ko sum variable mein add karte jao.
#include <stdio.h>
int main() {
int n, i, sum = 0;
printf("Enter n: ");
scanf("%d", &n);
for (i = 1; i <= n; i++) {
sum = sum + i; // har baar current i ko sum mein add kar rahe hain
}
printf("Sum = %d", sum);

18
return 0;
}

Input: 5 → Output: Sum = 15 (1+2+3+4+5=15)

4.7 Sum of Given N Numbers (User Input)

Logic: Yahan N numbers khud user input karega (fixed range nahi, jo bhi user de).
#include <stdio.h>
int main() {
int n, i, num, sum = 0;
printf("How many numbers? ");
scanf("%d", &n);
for (i = 1; i <= n; i++) {
printf("Enter number %d: ", i);
scanf("%d", &num);
sum = sum + num;
}
printf("Sum = %d", sum);
return 0;
}

Input: n=3, numbers: 10 20 30 → Output: Sum = 60

4.8 Integer Division

Logic: / operator do integers ke beech use hone par sirf quotient deta hai (decimal
part cut ho jaata hai). Remainder ke liye % use karte hain.
#include <stdio.h>
int main() {
int a = 17, b = 5;
printf("Quotient = %d\n", a / b); // integer division
printf("Remainder = %d\n", a % b);
return 0;
}

Output:
Quotient = 3
Remainder = 2
Common Mistake: int / int hamesha int result deta hai. Agar decimal chahiye to
kam se kam ek operand ko float banana padta hai: (float)a / b.

19
4.9 Digit Reversing

Logic: Number ka last digit %10 se nikalo, use reverse number mein jodo, phir original
number ko /10 karke last digit hata do — jab tak number 0 na ho jaaye.
#include <stdio.h>
int main() {
int num, rev = 0, digit;
printf("Enter a number: ");
scanf("%d", &num);
while (num != 0) {
digit = num % 10; // last digit nikala
rev = rev * 10 + digit; // reverse number mein jodo
num = num / 10; // last digit hata diya
}
printf("Reversed number = %d", rev);
return 0;
}

Input: 1234 → Output: Reversed number = 4321


Dry run samjho (num=1234): | Step | num | digit | rev | |—|—|—|—| | 1 | 1234 | 4 |
4 | | 2 | 123 | 3 | 43 | | 3 | 12 | 2 | 432 | | 4 | 1 | 1 | 4321 | | 5 | 0 | loop khatam | 4321 |

4.10 Table Generation for N

#include <stdio.h>
int main() {
int n, i;
printf("Enter number: ");
scanf("%d", &n);
for (i = 1; i <= 10; i++) {
printf("%d x %d = %d\n", n, i, n * i);
}
return 0;
}

Input: 5 → Output:
5 x 1 = 5
5 x 2 = 10
...
5 x 10 = 50

20
4.11 Factorial of a Number

Logic: n! = n * (n-1) * (n-2) * ... * 1. Loop se ya recursion se calculate karte


hain.
#include <stdio.h>
int main() {
int n, i;
long fact = 1; // long isliye kyunki factorial jaldi bada ho jaata hai
printf("Enter a number: ");
scanf("%d", &n);
for (i = 1; i <= n; i++) {
fact = fact * i;
}
printf("Factorial = %ld", fact);
return 0;
}

Input: 5 → Output: Factorial = 120 (5×4×3×2×1=120)


Common Mistake: fact ko 0 se initialize karna — agar aisa karoge to fact = fact
* i hamesha 0 hi rahega. Hamesha multiplication ke liye variable ko 1 se initialize
karo (addition ke liye 0 se).

4.12 Sine Series (Taylor Series)

Formula: sin(x) = x - x³/3! + x⁵/5! - x⁷/7! + …


#include <stdio.h>
#include <math.h>
int main() {
float x, sum = 0, term;
int n, i;
printf("Enter x (in radians) and number of terms: ");
scanf("%f %d", &x, &n);

for (i = 0; i < n; i++) {


term = pow(-1, i) * pow(x, 2*i+1) / fact_helper(2*i+1);
sum += term;
}
printf("sin(x) = %f", sum);
return 0;
}

// helper function to calculate factorial (since math.h doesn't have it directly)


long fact_helper(int num) {
long f = 1;
for (int j = 1; j <= num; j++) f *= j;

21
return f;
}

Concept samjho: Sine series ek infinite series hai jo trigonometric sin(x) ki value
approximate karti hai bina calculator/library function use kiye. Har term mein power
aur factorial dono badhte jaate hain, aur sign alternate (+, -, +, -) hota hai — isliye
pow(-1, i) use kiya jaata hai sign flip karne ke liye.
Note: Compile karte waqt -lm flag lagana padta hai math functions ke liye: gcc
file.c -o file -lm

4.13 Cosine Series (Taylor Series)

Formula: cos(x) = 1 - x²/2! + x⁴/4! - x⁶/6! + …


#include <stdio.h>
#include <math.h>

long factorial(int num) {


long f = 1;
for (int j = 1; j <= num; j++) f *= j;
return f;
}

int main() {
float x, sum = 0, term;
int n, i;
printf("Enter x (radians) and number of terms: ");
scanf("%f %d", &x, &n);

for (i = 0; i < n; i++) {


term = pow(-1, i) * pow(x, 2*i) / factorial(2*i);
sum += term;
}
printf("cos(x) = %f", sum);
return 0;
}

4.14 Pascal’s Triangle

Logic: Har row mein binomial coefficients hote hain. Simplest approach: nested loop
se nCr formula use karna, ya pichli value se next value calculate karna.
#include <stdio.h>
int main() {
int rows, i, j, num;

22
printf("Enter number of rows: ");
scanf("%d", &rows);

for (i = 0; i < rows; i++) {


num = 1;
for (j = 0; j <= i; j++) {
printf("%d ", num);
num = num * (i - j) / (j + 1); // agla coefficient calculate karne ka for
}
printf("\n");
}
return 0;
}

Input: 5 → Output:
1
1 1
1 2 1
1 3 3 1
1 4 6 4 1
Concept samjho: Har number apne upar wali row ke do numbers ka sum hota hai (jo
humne yahan formula num*(i-j)/(j+1) se directly calculate kiya, taaki nested loop
se dubara calculation na karni pade).

4.15 Prime Number Check

Logic: Number sirf 1 aur khud se divide hota ho (2 se lekar sqrt(n) tak koi divisor na
ho) to woh prime hai.
#include <stdio.h>
int main() {
int num, i, isPrime = 1;
printf("Enter a number: ");
scanf("%d", &num);

if (num <= 1) {
isPrime = 0; // 1 aur usse chhote numbers prime nahi hote
} else {
for (i = 2; i * i <= num; i++) {
if (num % i == 0) {
isPrime = 0; // agar koi divisor mil gaya to prime nahi hai
break;
}
}
}

23
if (isPrime)
printf("%d is Prime", num);
else
printf("%d is Not Prime", num);
return 0;
}

Input: 17 → Output: 17 is Prime


Common Mistake: Loop ko i < num tak chalana (inefficient) — sirf i*i <= num (i.e.,
sqrt(num) tak) chalana kaafi hai, kyunki agar num ka koi factor sqrt(num) se bada hai
to uska corresponding factor sqrt(num) se chhota hoga jo pehle hi mil jaayega.

4.16 Factors of a Number

#include <stdio.h>
int main() {
int num, i;
printf("Enter a number: ");
scanf("%d", &num);
printf("Factors of %d: ", num);
for (i = 1; i <= num; i++) {
if (num % i == 0) {
printf("%d ", i);
}
}
return 0;
}

Input: 12 → Output: Factors of 12: 1 2 3 4 6 12

4.17 Perfect Number

Logic: Ek number “perfect” hota hai agar uske saare factors (khud ko chhod kar) ka
sum khud number ke barabar ho. Jaise 6 = 1+2+3.
#include <stdio.h>
int main() {
int num, i, sum = 0;
printf("Enter a number: ");
scanf("%d", &num);

for (i = 1; i < num; i++) {


if (num % i == 0) {
sum = sum + i; // proper divisors ka sum

24
}
}

if (sum == num)
printf("%d is a Perfect Number", num);
else
printf("%d is Not a Perfect Number", num);
return 0;
}

Input: 28 → Output: 28 is a Perfect Number (1+2+4+7+14=28)

4.18 GCD (Greatest Common Divisor) of Two Numbers

Logic (Euclidean Algorithm): GCD(a,b) = GCD(b, a%b), jab tak b=0 na ho jaaye —
tab a hi answer hoga.
#include <stdio.h>
int main() {
int a, b, temp;
printf("Enter two numbers: ");
scanf("%d %d", &a, &b);

while (b != 0) {
temp = b;
b = a % b;
a = temp;
}
printf("GCD = %d", a);
return 0;
}

Input: 36 60 → Output: GCD = 12


Concept samjho: Euclidean algorithm bahut efficient hai kyunki har step mein num-
bers chhote hote jaate hain (modulus operation se), isliye normal “check every num-
ber” approach se kaafi fast hai.

4.19 Swapping of Two Numbers

Method 1: Using a temporary variable


#include <stdio.h>
int main() {
int a = 5, b = 10, temp;
printf("Before swap: a=%d, b=%d\n", a, b);

25
temp = a; // a ki value temp mein save
a = b; // b ki value a mein
b = temp; // temp (original a) ki value b mein

printf("After swap: a=%d, b=%d\n", a, b);


return 0;
}

Output:
Before swap: a=5, b=10
After swap: a=10, b=5
Method 2: Without temporary variable (using arithmetic)
a = a + b;
b = a - b; // yeh original a ke barabar ho jaata hai
a = a - b; // yeh original b ke barabar ho jaata hai

Common Mistake: Method 2 mein overflow ho sakta hai agar a+b variable ki max-
imum limit se bada ho jaaye — isliye temp variable wala method safer aur zyada
preferred hai.

Section 4 Summary (Quick Recap)

• Har arithmetic problem ka core loop/condition-based logic samajhna zaroori hai,


sirf code yaad karna nahi.
• Modulus (%) even/odd, digit extraction, aur GCD jaisi problems mein bahut use
hota hai.
• Factorial/Sum jaisi problems mein initialization variable (fact=1 ya sum=0) sahi
rakhna critical hai.
• Prime check mein sqrt(n) tak hi loop chalana efficient approach hai.
• Swapping temp variable se safe hoti hai, arithmetic method se overflow ka risk
hota hai.

SECTION 5: FUNCTIONS
Function ek self-contained block of code hai jo ek specific task perform karta hai. Ye
code ko organize, reusable aur readable banata hai.

5.1 Basic Types of Functions

1. Library functions (built-in) - pehle se C library mein defined hote hain, jaise
printf(), sqrt(), strlen().
2. User-defined functions - programmer khud banata hai apni zaroorat ke hisaab
se, jaise add(), factorial().

26
5.2 Function Declaration, Definition aur Call

Declaration (Prototype): Compiler ko batata hai ki function ka naam, return type,


aur parameters kya hain — bina body ke.
int add(int, int); // declaration/prototype

Definition: Function ka actual code (body) likhna.


int add(int a, int b) { // definition
return a + b;
}

Call: Function ko actually use/invoke karna.


int result = add(5, 3); // function call

Full example:
#include <stdio.h>

int add(int a, int b); // 1. Declaration

int main() {
int result = add(5, 3); // 3. Call
printf("Sum = %d", result);
return 0;
}

int add(int a, int b) { // 2. Definition


return a + b;
}

Output: Sum = 8
Concept samjho: Declaration compiler ko sirf ek “promise” deta hai ki function aage
kahin defined milega, taaki compiler main() mein call ko sahi se samajh sake, chahe
actual definition function ke baad mein likhi ho. Agar declaration na ho aur definition
main() ke baad ho, to compiler error de sakta hai (“implicit declaration”).

5.3 Types of Functions (Based on Parameters and Return Value)

Type Example
No arguments, no return value void greet()
No arguments, return value int getNumber()
Arguments, no return value void display(int x)
Arguments, return value int add(int a, int b)

27
Type Example

#include <stdio.h>

void greet() { // no argument, no return


printf("Hello!\n");
}

int getNumber() { // no argument, return value


return 100;
}

void display(int x) { // argument, no return


printf("Value = %d\n", x);
}

int add(int a, int b) { // argument, return value


return a + b;
}

int main() {
greet();
int n = getNumber();
display(n);
printf("Sum = %d", add(3, 4));
return 0;
}

Output:
Hello!
Value = 100
Sum = 7

5.4 Parameter Passing: Call by Value vs Call by Reference

Call by Value Function ko variable ki copy milti hai. Function ke andar changes
sirf uss copy par hote hain, original variable change nahi hota.
#include <stdio.h>

void modify(int x) {
x = x + 10; // sirf local copy change ho rahi hai
printf("Inside function: x = %d\n", x);
}

28
int main() {
int a = 5;
modify(a);
printf("Outside function: a = %d\n", a); // original 'a' unchanged
return 0;
}

Output:
Inside function: x = 15
Outside function: a = 5

Call by Reference Function ko variable ka address diya jaata hai (pointer ke


through). Isliye function ke andar changes original variable ko bhi affect karte
hain.
#include <stdio.h>

void modify(int *x) { // pointer parameter - address receive kar raha hai
*x = *x + 10; // *x se original variable ki value access/change ho ra
printf("Inside function: x = %d\n", *x);
}

int main() {
int a = 5;
modify(&a); // 'a' ka address pass kar rahe hain
printf("Outside function: a = %d\n", a); // original 'a' changed!
return 0;
}

Output:
Inside function: x = 15
Outside function: a = 15
Concept samjho: Call by value mein function apna alag memory space use karta hai
(copy), isliye original safe rehta hai. Call by reference mein function seedha original
variable ke memory address par kaam karta hai, isliye original bhi change ho jaata
hai. Yeh concept swapping do numbers using functions jaisi problems mein bahut
zaroori hota hai — swap sirf call by reference se hi possible hai, call by value se nahi.
Common Mistake: Swap function call by value se likhna aur expect karna ki original
values swap ho jaayengi — yeh kabhi nahi hoga, kyunki function ke paas sirf copies
hoti hain.

5.5 Scope of Variables

Scope batata hai ki variable program ke kis part mein accessible/visible hai.

29
1. Local variables - kisi function/block ke andar declare hote hain, sirf usi function
ke andar accessible hote hain.
2. Global variables - function ke bahar declare hote hain, poore program mein
kahin bhi accessible hote hain.
#include <stdio.h>

int globalVar = 100; // global variable - poore program mein accessible

void display() {
int localVar = 5; // local variable - sirf is function ke andar accessible
printf("Local: %d, Global: %d\n", localVar, globalVar);
}

int main() {
printf("Global from main: %d\n", globalVar); // yeh access ho sakta hai
display();
// printf("%d", localVar); // ERROR - localVar yahan accessible nahi hai
return 0;
}

Output:
Global from main: 100
Local: 5, Global: 100
Common Mistake: Global variables ka zaroorat se zyada use karna — yeh code ko
debug karna mushkil bana deta hai kyunki koi bhi function unko kahin se bhi change
kar sakta hai. Best practice hai local variables aur parameters ka use karna, jab tak
global zaroori na ho.

5.6 Storage Classes

Storage class batati hai ki variable ka scope, lifetime, aur default value kya hoga.

Storage Class Scope Lifetime Default Value


auto Local Function ke andar Garbage
hi
static Local (but value Poore program ki 0
retain hoti hai) lifetime
extern Global Poore program ki 0
lifetime
register Local Function ke andar Garbage
hi

30
#include <stdio.h>

void counter() {
static int count = 0; // static - value function calls ke beech bhi retain hoti h
count++;
printf("Count = %d\n", count);
}

int main() {
counter(); // Count = 1
counter(); // Count = 2
counter(); // Count = 3
return 0;
}

Output:
Count = 1
Count = 2
Count = 3
Concept samjho: Normal (auto) local variable har function call mein naya banta
hai (reset ho jaata hai), lekin static variable sirf ek baar initialize hota hai aur uski
value function calls ke beech bhi yaad rehti hai. Yahan agar static nahi likhte, to
har call mein count 0 se start hokar 1 hi print karta, kabhi 2 ya 3 nahi.
extern use hota hai jab variable kisi doosri file mein defined ho aur usse current file
mein use karna ho (multi-file programs mein).

5.7 Recursion

Recursion ek technique hai jisme function khud ko call karta hai. Har recursive
function mein 2 cheezein zaroori hain: 1. Base case - woh condition jahan recursion
rukta hai (warna infinite recursion ho jaayega aur stack overflow error aayega). 2.
Recursive case - jahan function khud ko smaller problem ke sath call karta hai.
#include <stdio.h>

int factorial(int n) {
if (n == 0 || n == 1) // BASE CASE - yahan recursion rukta hai
return 1;
else
return n * factorial(n - 1); // RECURSIVE CASE - khud ko chhote problem ke sa
}

int main() {
int result = factorial(5);
printf("Factorial = %d", result);

31
return 0;
}

Output: Factorial = 120


Dry run samjho (factorial(5)):
factorial(5) = 5 * factorial(4)
= 5 * (4 * factorial(3))
= 5 * (4 * (3 * factorial(2)))
= 5 * (4 * (3 * (2 * factorial(1))))
= 5 * (4 * (3 * (2 * 1)))
= 5 * 4 * 3 * 2 * 1 = 120
Recursion vs Loop: Recursion internally ek call stack use karta hai — har call
apne aap ko memory mein “wait” karta hai jab tak base case na mile, phir sab ek-ek
karke “unwind” (return) hote hain. Loop isse zyada memory-efficient hota hai, lekin
recursion kuch problems (jaise tree traversal, Fibonacci, Towers of Hanoi) ke liye
zyada natural aur readable solution deta hai.
Common Mistake: Base case likhna hi bhool jaana — isse function infinite baar
khud ko call karta rahega jab tak program crash na ho jaaye (“Stack Overflow”
error).
int badFactorial(int n) {
return n * badFactorial(n - 1); // GALAT - koi base case nahi hai, kabhi rukega h
}

Section 5 Summary (Quick Recap)

• Function = declaration (prototype) + definition (body) + call (usage).


• Types: no-arg/no-return, no-arg/return, arg/no-return, arg/return.
• Call by value: copy pass hoti hai, original safe rehta hai.
• Call by reference: address (pointer) pass hota hai, original bhi change hota
hai.
• Scope: Local (function ke andar hi accessible) vs Global (poore program mein).
• Storage classes: auto (default, temporary), static (value retain karta hai calls
ke beech), extern (dusri file se access), register (fast access ke liye CPU register
mein).
• Recursion: function khud ko call karta hai; hamesha ek base case hona chahiye
warna infinite recursion/stack overflow hoga.

FINAL QUICK REVISION (Poore Syllabus Ka Recap)

32
Topic Key Point
History C - Dennis Ritchie, 1972, Bell Labs,
UNIX ke liye
Structure Preprocessor → Global declarations →
main() → user functions
Tokens Keywords, Identifiers, Constants,
Strings, Operators, Symbols
Data Types int, float, char, double (sath mein format
specifiers %d %f %c %lf)
Operators Arithmetic, Relational, Logical,
Assignment, Increment/Decrement,
Bitwise, Ternary
I/O printf/scanf (stdio.h), getch (conio.h,
non-standard), getchar/putchar
(portable)
Preprocessor #include (header add), #define
(macro/constant)
Control Structures if/if-else/nested-if, switch (break zaroori),
while/do-while/for,
break/continue/goto/exit
Arithmetic Problems Sabme ek common pattern: input →
loop/condition → process → output
Functions Declaration+Definition+Call; Call by
value (copy) vs Call by reference
(address); Scope (local/global); Storage
classes (auto/static/extern/register);
Recursion (base case + recursive case)

All the best for your exam! Practice karte raho, especially code likh kar khud
dry-run karo — usse concepts pakke ho jaayenge.

33

You might also like