कंटेंट को अपडेट किया 02/03/2023
ऑपरेटर किसी भी प्रोग्रामिंग भाषा में उपयोग किए जाने वाले प्रतीक हैं जो कंप्यूटर को गणितीय या तार्किक संचालन करने के लिए निर्देशित करते हैं।
ऑपरेटर्स के प्रकार (Types of Operators) - 'सी' प्रोग्रामिंग भाषा में निम्नलिखित आठ प्रकार के ऑपरेटर होते हैं।
- एसाइन्मेन्ट ऑपरेटर (Assignment Operators)
- कन्डिशनल ऑपरेटर (Conditional Operators)
- अंकगणितीय ऑपरेटर (Arithmetic Operators)
- तार्किक ऑपरेटर (Logical Operators)
- सम्बन्धीकारी ऑपरेटर (Relational Operators)
- बिटवाइस ऑपरेटर (Bitwise Operators)
- इन्क्रीमैन्ट एण्ड डिक्रीमैन्ट ऑपरेटर (Increment and Decrement Operators)
- अन्य ऑपरेटर (Other Operators)
Syntaxe:-
#include <stdio.h>
int main()
{
int num1 = 12;
int num2 = 7;
int sum = num1 + num2;
int diff = num1 - num2;
int product = num1 * num2;
int quotient = num1 / num2;
int remainder = 12 % 7;
printf("Sum : %d\n", sum);
printf("Difference : %d\n", diff);
printf("Product : %d\n", product);
printf("Quotient : %d\n", quotient);
printf("Remainder : %d\n", remainder);
}
Output :
Sum : 19
Difference : 5
Product : 84
Quotient : 1
Remainder : 5
सी में ऑपरेटरों की प्राथमिकता
C ऑपरेटर की प्राथमिकता अभिव्यक्ति में शब्दों के समूह को निर्धारित करती है और यह तय करती है कि अभिव्यक्ति का मूल्यांकन कैसे किया जाता है। कुछ ऑपरेटरों की दूसरों की तुलना में उच्च प्राथमिकता होती है; उदाहरण के लिए, गुणन संकारक की अतिरिक्त संकारक की तुलना में उच्च प्राथमिकता है। उदाहरण के लिए, x = 7 + 3 * 2; यहाँ, x को 13 निर्दिष्ट किया गया है, 20 नहीं क्योंकि ऑपरेटर * की + से उच्च प्राथमिकता है, इसलिए इसे पहले 3 * 2 से गुणा किया जाता है और फिर 7 में जोड़ा जाता है। यहाँ, उच्चतम प्राथमिकता वाले ऑपरेटर तालिका के शीर्ष पर दिखाई देते हैं, वे सबसे निचले तल के साथ। एक अभिव्यक्ति के भीतर, उच्च प्राथमिकता वाले ऑपरेटरों का पहले मूल्यांकन किया जाएगा।