Introduction
Programming में हमें अक्सर calculations करने की जरूरत होती है, जैसे addition, subtraction, multiplication आदि।
C language में इन mathematical operations को perform करने के लिए Arithmetic Operators का उपयोग किया जाता है।
ये operators variables और values पर काम करके result देते हैं।
Definition
Arithmetic Operators वे operators होते हैं जिनका उपयोग mathematical calculations करने के लिए किया जाता है।
Types of Arithmetic Operators
| Operator | Meaning |
|---|---|
| + | Addition |
| – | Subtraction |
| * | Multiplication |
| / | Division |
| % | Modulus (remainder) |
Example
#include <stdio.h>
int main()
{
int a = 10, b = 3;
printf("%d\n", a + b); // 13
printf("%d\n", a - b); // 7
printf("%d\n", a * b); // 30
printf("%d\n", a / b); // 3
printf("%d\n", a % b); // 1
return 0;
}
Important Note
/division integer value देता है (decimal part हट जाता है)%operator केवल integers पर ही काम करता है
Real World Example
मान लो आप एक दुकान पर गए:
- आपने 3 items खरीदे, हर एक की कीमत 50 रुपये है
Total price = 3 × 50 = 150
या:
- आपके पास 100 रुपये हैं और आपने 30 रुपये खर्च किए
बाकी पैसे = 100 – 30 = 70
इसी तरह real life में जो calculations करते हैं, वही programming में Arithmetic Operators करते हैं।
Exam Points
- Arithmetic operators mathematical operations के लिए use होते हैं
%operator remainder निकालता है- Integer division में decimal part नहीं आता
- ये operators expression बनाने में use होते हैं