Arithmetic operators c++ In Hindi

Arithmetic operators c++ In Hindi

C++ प्रोग्रामिंग लैंग्वेज में अरिथमेटिक ऑपरेटर्स का यूज़ C++ प्रोग्राम में डिफाइन डिक्लेअर वेरिएबल पर ऐड, सब्सट्रेशन, मल्टिप्लिकेशन, डिवीज़न, और मॉड्यूलस (शेष) जैसे बेसिक अर्थमेटिक मैथमेटिकल ऑपरेशन अप्लाई या परफॉर्म करने में किया जाता है। अरिथमेटिक ऑपरेटर्स प्रोग्रामर डिक्लेअर पैरामीटर वेरिएबल जिसमे इंटीजर और फ्लोटिंग-पॉइंट जैसे डाटा टाइप (जिसमे int, float, और double) पर अरिथमेटिक ऑपरेटर्स अप्लाई करने में किया जा सकता है।

Arithmetic operators c++ In Hindi

Popular Arithmetic Operators

Operator SymbolOperator NameOperator DescriptionOperator Example
+AdditionUse to Adds two different int, double, float, long double operands.p + q
SubtractionUse to Subtracts the second operand from the first operand. Larger value subtracts with smaller valuep – q
*MultiplicationUsed to Multiplies two different integer operands.p * q
/DivisionUsed to Divides the first operand by the second user define operand value.p / q
%Modulus (Remainder)Used to Returns the remainder of the division of two user defined operands with remainder or modulus.p % q

Addition (+) Arithmetic Operators in C++.

C++ प्रोग्राम में दो इंडिविजुअल इन्टिजर, फ्लोट, डबल, या लॉन्ग डबल डाटा टाइप वेरिएबल न्यूमेरिक वैल्यू को  ऐड करने में किया जाता है।

Example of Addition (+) Arithmetic Operators.

#include <iostream>

using namespace std;

int main() {

    int p = 3, q = 4;

    int total = p + q;  // the total is = 7

    cout << “The total is – ” <<total << endl;  // Result – total – 7

    return 0;

}

Subtraction (-) Arithmetic Operators in C++.

C++ प्रोग्राम में दो इंडिविजुअल इन्टिजर, फ्लोट, डबल, या लॉन्ग डबल डाटा टाइप वेरिएबल न्यूमेरिक वैल्यू को फर्स्ट लार्ज बिग वैल्यू में से सेकंड स्माल न्यूमेरिक वैल्यू को सब्सट्रैक्ट करने में किया जाता है।

Example of Subtraction (-) Arithmetic Operators.

#include <iostream>

using namespace std;

int main() {

    int p = 7, q = 2;

    int subtract = p – q;  // the subtract = 5

    cout << “the subtraction is – ” << subtract<< endl;  // Output: subtract – 5

    return 0;

}

Multiplication (*) Arithmetic Operators in C++.

C++ प्रोग्राम में दो इंडिविजुअल इन्टिजर, फ्लोट, डबल, या लॉन्ग डबल डाटा टाइप वेरिएबल न्यूमेरिक वैल्यू को आपस में मल्टिप्लाय करने में किया जाता है।

Example of Multiplication (*) Arithmetic Operators.

#include <iostream>

using namespace std;

int main() {

    int p = 7, q = 4;

    int multiplication = p * q;  // multiplication is – 28

    cout << “multiplication is – ” << multiplication << endl;  // Result – multiplication – 28

    return 0;

}

Division (/) Arithmetic Operators in C++.

C++ प्रोग्राम में दो इंडिविजुअल इन्टिजर, फ्लोट, डबल, या लॉन्ग डबल डाटा टाइप वेरिएबल न्यूमेरिक वैल्यू पहली लार्ज बड़ी न्यूमेरिक वैल्यू को दूसरी स्माल वैल्यू से डिवाइड करने में किया जाता है। यदि डिवीज़न में दोनों ऑपरेंड इंटीजर डाटा टाइप हैं, तो आउटपुट रिज़ल्ट एक इंटीजर वैल्यू होगा और इसमें फ्रैक्शनल पार्ट अपने आप ट्रंकेट हो जाता है। इसमें फ्लोटिंग-पॉइंट डिवीज़न न्यूमेरिक वैल्यू के लिए आउटपुट रिज़ल्ट में डेसिमल वैल्यू इन्क्लुड हो सकते हैं।

Example of Division (/) Arithmetic Operators.

#include <iostream>

using namespace std;

int main() {

    // here we perform Integer division operation

    int p = 30, q = 3;

    int division = p / q;  // division is – 10

    cout << “the integer division value is – ” << division << endl;

    // here we perform Floating-point division operation

    double r = 9.0, s = 4.0;

    double output = r / s;  // floating division is = 2.25

    cout << “the floating division value  is – ” << output << endl;

    // Comparison of integer with floating division example

    cout << “11 / 5 = ” << 11 / 5 << endl;      // Integer division value is – 2

    cout << “11.0 / 5 = ” << 11.0 / 5 << endl;  // Floating-point division value is – 2.2…

    return 0;

}

Integer division method.

किसी C++ प्रोग्राम में, यदि दोनों यूजर डिफाइन ऑपरेंड इंटीजर डाटा टाइप वैल्यू हैं, तो आउटपुट रिजल्ट भी एक इंटीजर वैल्यू के रूप में होता है। और इसमें फ्रैक्शनल पार्ट हिस्सा छोटा या रिमूव कर दिया जाता है. सिर्फ राउंड वैल्यू ही डिस्प्ले होती है।

11 / 5 का रिजल्ट 2 होता है (2.2 नहीं)।

Floating-point division method.

किसी C++ प्रोग्राम में, यदि दोनों यूजर डिफाइन ऑपरेंड फ्लोटिंग डाटा टाइप वैल्यू हैं, यहाँ कम से कम एक ऑपरेंड फ्लोटिंग-पॉइंट डाटा टाइप जैसे फ्लोट या डबल डाटा टाइप है. तो आउटपुट रिजल्ट एक फ्लोटिंग-पॉइंट नंबर के रूप में होगा। जिसमे राउंड वैल्यू नहीं डिस्प्ले होती है, और उसमे फ्रॅक्शनल पार्ट भी मौजूद होता है।

11.0 / 5 का रिजल्ट 2.2 होता है….

Modulus (%) Arithmetic Operators in C++.

किसी C++ प्रोग्राम में, यदि दोनों यूजर डिफाइन ऑपरेंड इन्टिजर डाटा टाइप वैल्यू हैं, और मॉड्यूलस ऑपरेटर दो इंटीजर के बीच डिवीज़न के बाद बचा हुआ रिमाइंडर रेष वैल्यू हिस्सा को डिस्प्ले करता है।

Example of Modulus (%) Arithmetic Operators.

#include <iostream>

using namespace std;

int main() {

    int p = 7, q = 3;

    int modulus = p % q;  // modulus is – 1

    cout << “the Remainder of modulus is – ” << modulus << endl;

    // other modulus operator examples

    cout << “11 % 3 = ” << 11 % 3 << endl;

    cout << “36 % 5 = ” << 36 % 5 << endl;

    return 0;

}

Modulus operator Rules in C++.

याद रहे C++ प्रोग्राम में मॉड्यूलस सिर्फ़ इंटीजर डाटा टाइप जिसमे int, long, आदि के लिए यूज़ या अप्लाई होता है। आप C++ प्रोग्राम में फ्लोटिंग-पॉइंट डाटा टाइप न्यूमेरिक वैल्यू के लिए इसे यूज़ नहीं कर सकते है।

यहाँ p % q, वेरिएबल में p को q से डिवाइड करने पर उसके रिमाइंडर वैल्यू को डिस्प्ले करता है।

Modulus operator rules example.

यहाँ 11 % 3, 2 रिमाइंडर आउटपुट डिस्प्ले करता है. क्योंकि 11 ÷ 3 = 3 रिमाइंडर 2 होता है।

यहाँ 36 % 5, 1 रिमाइंडर आउटपुट डिस्प्ले करता है. क्योंकि 36 ÷ 5 = 7 रिमाइंडर 1 होता है।

Arithmetic Operators Precedence in C++.

C++ प्रोगाम में अरिथमेटिक प्रिसिडेंस ऑपरेटर्स का एक स्पेशल ऑर्डर ऑफ़ प्रिसिडेंस डिस्प्ले वैल्यू होता है, जो मौजूदा प्रोग्राम में यह फिक्स करता है कि किसी भी प्रोग्रामिंग एक्सप्रेशन में अरिथमेटिक ऑपरेशन किस सीक्वेंस में परफॉर्म किये जाते हैं। यहाँ बेसिक रूल्स यह है, कि अरिथमेटिक मल्टिप्लिकेशन, डिवीज़न, और मॉड्यूलस, जैसे अरिथमेटिक ऑपरेशन्स का प्रिसिडेंस एडिशन और सबट्रैक्शन से अधिक होता है।

Example of Arithmetic Operators Precedence.

#include <iostream>

using namespace std;

int main() {

    int p = 7, q = 8, r = 2;

    int output = p + q * r;  // output = 7 + (8 * 2) = 23

    cout << “the output of Precedence operator is – ” << output << endl;  // output, Result is – 23

    return 0;

}

Here in the above example.

यहाँ q * r को पहले इवैल्यूएट किया जाता है, क्योंकि यहाँ मल्टिप्लिकेशन ऑपरेटर को एडिशन से ज़्यादा प्रायोरिटी प्रोवाइड की जाती है।

Arithmetic Operators Precedence Brackets.

यहाँ आप ब्रैकेट () पैरेंथेसिस सिंबल का यूज़ करके ऑपरेशन्स के ऑर्डर को मॉडिफाई कर सकते हैं, जिससे की ऑपरेशन्स का एक खास सीक्वेंस एक्सेक्यूट हो सके।

Arithmetic Precedence Brackets example.

#include <iostream>

using namespace std;

int main() {

    int p = 8, q = 4, r = 3;

    int output = (p + q) * r;  // result = (8 + 4) * 3 = 36

    cout << ” the output is – ” << output << endl;  // Result is – 36

    return 0;

}

Compound assignment operators in C++.

C++ प्रोग्रामिंग मल्टीप्ल कंपाउंड असाइनमेंट ऑपरेटर्स को भी सपोर्ट करते है. जो यूजर डिफाइन डिक्लेअर अरिथमेटिक ऑपरेशन्स पैरामीटर को असाइनमेंट के साथ कंबाइन कर डिस्प्ले करते हैं।

Compound AssignmentEquivalent withExample withCompound Assignment operator Description
+=p = p + qp += qHere it Adds q value to p variable and assigns the result to p value.
-=p = p – qp -= qHere it Subtracts q value from p value and assigns the result to p variable.
*=p = p * qp *= qHere it Multiplies p by q variable value and assigns the result to p variable.
/=p = p / qp /= qHere it Divides p value by q value and assigns the result to  p value.
%=p = p % qp %= qHere it Assigns the remainder of p divided by q to p.

Compound assignment operators example.

#include <iostream>

using namespace std;

int main() {

    int p = 36, q = 3;

    p += q;  // p = p + q => 39

    cout << “the p += q expression – ” << p << endl;

    p -= q;  // p = p – q => 36

    cout << “the p -= q expression – ” << p << endl;

    p *= q;  // p = p * q => 108

    cout << “the p *= q expression – ” << p << endl;

    p /= q;  // p = p / q => 36

    cout << “the p /= q expression – ” << p << endl;

    return 0;

}

Detail explanation of Arithmetic Operators

Operator nameOperators DescriptionOperators Example
+Addition Operators – here it Adds two different numeric operandsp + q
Subtraction Operators – here it Subtracts second operand from first operandp – q
*Multiplication Operators – here it Multiplies two different integer operandsp * q
/Division Operators – here it Divides first operand by second operandp / q
%Modulus Operators – here it Returns remainder of division valuep % q

Leave a Reply