Introduction
जब हम C language में program लिखते हैं, तो हम instructions देते हैं जिन्हें computer step-by-step execute करता है।
ये instructions दो मुख्य भागों में होते हैं:
- Expressions (जहाँ calculation या operation होता है)
- Statements (जो एक complete instruction होते हैं)
इन दोनों को समझना programming की logic बनाने के लिए बहुत जरूरी है।
Expressions
Definition
Expression values, variables और operators का combination होता है जो एक result produce करता है।
Example
int a = 10, b = 5;
int c = a + b;
यहाँ:
a + b→ expression है- इसका result = 15
Real World Example
मान लो आप shopping कर रहे हैं:
- Price = 100
- Discount = 20
Final price निकालना (100 – 20) = 80
यह calculation एक expression की तरह है।
Statements
Definition
Statement एक complete instruction होता है जो compiler द्वारा execute किया जाता है और यह semicolon (;) पर समाप्त होता है।
Example
int a = 10;
a = a + 5;
printf("%d", a);
हर line एक statement है
Types of Statements
- Declaration Statement
int a;
- Assignment Statement
a = 10;
- Control Statement
if (a > 5)
{
printf("Greater");
}
Real World Example
मान लो आप किसी को instructions दे रहे हैं:
- उठो
- पानी पियो
- स्कूल जाओ
हर instruction एक complete step है
इसी तरह programming में हर statement एक complete instruction होता है।
Difference Between Expression and Statement
| Expression | Statement |
|---|---|
| Result produce करता है | Instruction execute करता है |
| Operators + values का combination | Complete line of code |
| Example: a + b | Example: a = a + b; |
Exam Points
- Expression हमेशा एक value return करता है
- Statement एक complete instruction होता है
- हर statement semicolon (;) से खत्म होता है (except control blocks)
- Expression statement का हिस्सा हो सकता है