Introduction :-

    प्रोग्राम में विभिन्न प्रकार की गणना करने के लिए हमें विभिन्न प्रकार के फार्मूले प्रयोग में लेने होते हैं। जब हम कोई फार्मूला प्रयोग करते हैं तो उसमें Operator(ऑपरेटर) एवं Operand(ऑपरेंड) दोनों होते हैं Operator(ऑपरेटर) एवं Operandऑपरेंड) के समूह को Expression(एक्सप्रेशन) कहा जाता है उदाहरण के लिए:- 

        ((45 + 5) /2)  

    यह एक Expression(एक्सप्रेशन)  है जिसमें 45,  5, 3, Operand(ऑपरेंड)  है तथा +और /ऑपरेटर है। 

    इस प्रकार ऑपरेटर(operator) से आशय से किसी एक्सप्रेशन(explanation) के उस भाग से हैं जो यह बताता है कि कौन सा ऑपरेशन(operation) किया जाना है। वही ऑपरेंड(operand)  से आशय से एक्सप्रेशन (expression) के उस भाग से जो यह बताता है कि ऑपरेशन(operation) किस पर करना है। 

    Operator in C programming language:-

    Operator को  operand के आधार पर दो भागों में विभाजित किया जा सकता है, 

    (i) Unary

    unary से आशय  ऐसे ऑपरेटर से है जिन्हें मात्र एक ही  operand की आवश्यकता होती है। 

    Example के लिए यदि हम -45 लिखते हैं तो यहां पर माइनस(-) ऑपरेटर(-) यूनरी ऑपरेटर का उदाहरण होगा, क्योंकि इसके साथ मात्र एक ही ऑपरेंड की आवश्यकता है। 

    (ii) Binary

    बाइनरी से आशय ऐसे ऑपरेटर से हैं, जिन्हें 2  operand की आवश्यकता होती है।   
     
    Example के लिए यदि हम 45/2 लिखते हैं तो यहां '/' बायनरी का उदाहरण होगा क्योंकि इसमें दो ऑपरेंड  की आवश्यकता पड़ती है। 
    सी लैंग्वेज में प्रयोग किए जाने वाले ऑपरेटरों को हम निम्न भागों में विभाजित कर सकते हैं 
    1.  Arithmetic operator
    2. Relational operator
    3. Logical operator 
    4. Assignment operator 
    5. Increment and Decrement operator 
    6. Conditional operator 
    7. Bitwise operator 
    8. Special operator 

    इस अध्याय में हम Arithmetic operator(अंकगणितीय ऑपरेटर) और Relational operator(रिलेशनल ऑपरेटर) के बारे में जानेंगे बाकी के ऑपरेटर आने वाले तीन या चार अध्याय में पूरे करेंगे

    Arithmetic operator 

    ऐसे  Operation जो Mathematical(गणितीय) Number(संख्या) पर किए जाते हैं ऐसे Operators(ऑपरेटर्स) को  Arithmetic operator की  श्रेणी में आते हैं। 

    query boat, queryboat


    Operator Category Description
    + Unary + Operator
    - Unary - Operator
    + binary + Operator
    - binary - Operator
    * binary गुना करने के लिए
    / binary भाग देने के लिए
    % binary शेषफल ज्ञात करने के लिए


    निम्न Table C language  में Use किए जाने वाले  सभी Arithmetic operator(अंकगणितीय ऑपरेटर)  का उदाहरण  दिया गया हैं । मान लें कि variable  A में 20 है और variable  B में 10 है, तो −

    Operator Description Example
    + दो ऑपरेंड जोड़ता है। A + B = 30
    - दूसरे ऑपरेंड को पहले से घटाता है। A - B = 10
    *दोनों ऑपरेंड को गुणा करता है। A * B = 200
    / अंश को अंश से विभाजित करता है। A / B  = 2
    % Remainder(शेषफल) ज्ञात करना।5 % 2 = 1
    ++ इंक्रीमेंट ऑपरेटर integer value को 1 से बढ़ा देता है।A++ = 21
    -- डिक्रीमेंट ऑपरेटर integer value को 1 से घटा देता है।A-- = 19


    Example:-

    निम्न उदाहरण में Arithmetic Operator(addition) को समझाया गया हैं। 


        #include <stdio.h>
        #include <conio.h>
        void main()
        {
            printf("\nResult of 10 + 2 is : %d", 10 + 2);
            printf("\nResult of 8 + 6 is : %d", 8 + 6);
            printf("\nResult of 12 + 23 is : %d", 12 + 23);
            getch();
        }

    Output:-

    Result of 10 + 2 is : 12
    Result of 8 + 6 is : 14
    Result of 12 + 23 is : 35


    Explain Example:-

    ऊपर दिए गए उदाहरण में सबसे पहले  10 + 2 है,  चूंकि 10+2 = 12 होता हैं अतः Output  में पहली लाइन में "Result of 10 + 2 is : 12 " print हुआ हैं। यहाँ पर line printf("\nResult of 10 + 2 is : %d", 10 + 2);   में %dकी जगह 12 print हुआ हैं। इसी प्रकार  "Result of  8  + 6 is : 14" व "Result of  12 + 23  is : 35" print  हुआ हैं। 


    Example:-

    निम्न उदाहरण में  Arithmetic Operator(Substation) को समझाया गया हैं। 

        #include <stdio.h>
        #include <conio.h>
        void main()
        {
            printf("\nResult of 10 - 2 is : %d", 10 - 2);
            printf("\nResult of 8 - 6 is : %d", 8 - 6);
            printf("\nResult of 12 - 23 is : %d", 12 - 23);
            getch();
        }

    Output:-

    Result of 10 - 2 is : 8
    Result of 8 - 6 is : 2
    Result of 12 - 23 is : -11

    Explain Example:-

    ऊपर दिए गए उदाहरण में सबसे पहले  10 - 2 है,  चूंकि 10-2 = 8 होता हैं अतः Output  में पहली लाइन में "Result of 10 - 2 is : 8 " print हुआ हैं। यहाँ पर line  printf("\nResult of 10 - 2 is : %d", 10 - 2);  में %dकी जगह 8 print हुआ हैं। इसी प्रकार  "Result of  8  - 6 is : 2" व "Result of  12 - 23  is : -11" print  हुआ हैं। 


    Example:-

    निम्न उदाहरण में  Arithmetic Operator(Multiplication) को समझाया गया हैं। 


        #include <stdio.h>
        #include <conio.h>
        void main()
        {
            printf("\nResult of 10 * 2 is : %d", 10 * 2);
            printf("\nResult of 8 * 6 is : %d", 8 * 6);
            printf("\nResult of 12 * 23 is : %d", 12 * 23);
            getch();
        }

    Output:-

    Result of 10 * 2 is : 20
    Result of 8 * 6 is : 48
    Result of 12 * 23 is : 276


    Explain Example:-

    ऊपर दिए गए उदाहरण में सबसे पहले  10 * 2 है,  चूंकि 10*2 = 20 होता हैं अतः Output  में पहली लाइन में "Result of 10 * 2 is : 20 " print हुआ हैं। यहाँ पर line printf("\nResult of 10 * 2 is : %d", 10 * 2);   में%dकी जगह 20 print हुआ हैं। इसी प्रकार  "Result of  8  * 6 is : 48" व "Result of  12 * 23  is : 276" print  हुआ हैं। 

    Example:-

    निम्न उदाहरण में  Arithmetic Operator(Division) को समझाया गया हैं। 


        #include <stdio.h>
        #include <conio.h>
        void main()
        {
            printf("\nResult of 10 / 2 is : %d ", 10 / 2);
            printf("\nResult of 64 / 4 is : %d ", 64 / 4);
            printf("\nResult of 12 / 6 is : %d ", 12 / 6);

            getch();
        }

    Output:-

    Result of 10 / 2 is : 5
    Result of  64  /  4 is : 16
    Result of 12 / 6 is : 2


    Explain Example:-

    ऊपर दिए गए उदाहरण में सबसे पहले  10 / 2 है,  चूंकि 10/2 = 5 होता हैं अतः Output  में पहली लाइन में "Result of 10 / 2 is : 5 " print हुआ हैं। यहाँ पर  line  printf("\nResult of 10 / 2 is : %d ", 10 / 2);  में%dकी जगह 5 print हुआ हैं। इसी प्रकार  "Result of  64 / 4  is : 16" व "Result of  12 / 6  is : 2" print  हुआ हैं। 


    Example:-

    निम्न उदाहरण में  Arithmetic Operator(Module) को समझाया गया हैं। 


        #include <stdio.h>
        #include <conio.h>
        void main()
        {
            printf("\nResult of 10 % 2 is : ",10 % 2);
            printf("\nResult of 10 % 4   is : ",10 % 4);
            printf("\nResult of 4 % 10  is : ",4 % 10);
            printf("\nResult of -10 % 4  is : ",-10 % 4);
            printf("\nResult of 10 % -4  is : ",10 % -4);
            printf("\nResult of -10 % -4  is : ",-10 % -4);

            getch();
        }

    Output:-

    Result of 10 % 2 is : 0
    Result of 10 % 4   is : 2
    Result of 4 % 10  is : 4
    Result of -10 % 4  is : -2
    Result of 10 % -4  is : 2
    Result of -10 % -4  is : -2


    Explain Example:-

    ऊपर 👆 दिए गए उदाहरण में  Expiration  10%2 में चूंकि संख्या 10 संख्या 2 से पूरी तरह विभाजित होती हैं, अतः कोई शेषफल नहीं बचता हैं। वहीं 10%4 में संख्या 10 संख्या 4 से दो बार पूरी तरह विभाजित हो जाती हैं, तथा शेषफल 2 रहता हैं।   Expiration 4%10 में संख्या 4 संख्या 10 से एक बार भी पूरी तरह विभाजित नहीं होती हैं, अतः शेषफल में संख्या 4 स्वयं रह जाती हैं। 

    ऊपर 👆 दिए गए उदाहरण में शेषफल ज्ञात करने के लिए  निम्नांकित सूत्र का प्रयोग किया गया हैं:
    x - x / y * y
    उदाहरण के  लिए 10 % 4 में 10 की x के स्थान पर 4 को y के स्थान  पर रखने पर गणना निम्नानुसार होगी :

    = 10  - 10 / 4* 4
    = 10  -  2 * 4
    = 10 - 8
    = 2 


    Example:-


        #include <stdio.h>
        #include <conio.h>
        void main()
        {
            int a = 21;
            int b = 10;
            int c;
            // + Arithmetic operator
            c = a + b;
            printf("Line 1 - Value of c is %d\n", c);
            // - Arithmetic operator
            c = a - b;
            printf("Line 2 - Value of c is %d\n", c);
            // * Arithmetic operator
            c = a * b;
            printf("Line 3 - Value of c is %d\n", c);
            // / Arithmetic operator
            c = a / b;
            printf("Line 4 - Value of c is %d\n", c);
            // % Arithmetic operator
            c = a % b;
            printf("Line 5 - Value of c is %d\n", c);
            // ++ Arithmetic operator
            c = a++;
            printf("Line 6 - Value of c is %d\n", c);
            // -- Arithmetic operator
            c = a--;
            printf("Line 7 - Value of c is %d\n", c);
            getch();
        }
       

    Output:-

    Line 1 - Value of c is 31
    Line 2 - Value of c is 11
    Line 3 - Value of c is 210
    Line 4 - Value of c is 2
    Line 5 - Value of c is 1
    Line 6 - Value of c is 21
    Line 7 - Value of c is 22