Increment and Decrement operators c++ In Hindi
C++ प्रोग्रामिंग लैंग्वेज में इन्क्रीमेंट (++) और डिक्रीमेंट (–) ऑपरेटर का यूज़ किसी यूजर डिफाइन पैरामीटर वेरिएबल की करंट वैल्यू को 1 नंबर वैल्यू से इनक्रीस या डिक्रीस करने में किया जाता है। इन्क्रीमेंट (++) और डिक्रीमेंट (–) ऑपरेटर एक शॉर्टहैंड प्रोग्राम लूप स्टेटमेंट या नोटेशन हैं. जो किसी यूजर डिफाइन प्रोग्राम डिक्लेअर वेरिएबल की वैल्यू को मौजूदा कंडीशन एक्सप्रेशन के अनुसार इनक्रीस या डिक्रीस कर अपडेट करने में हेल्प करते हैं।

So, let’s understand the increment (++) and decrement (–) operator concepts in C++ programming.
Increment and Decrement Operator Concepts in C++.
- Pre-increment (++p) expression – यह मौजूदा C++ प्रोगाम में यूजर डिफाइन वेरिएबल कंडीशन एक्सप्रेशन में यूज़ होने से पहले p पैरामीटर की वैल्यू को 1 से इनक्रीस करता है।
- Post-increment (p++) expression – यह मौजूदा C++ प्रोगाम में यूजर डिफाइन वेरिएबल कंडीशन एक्सप्रेशन में यूज़ होने के बाद p पैरामीटर की वैल्यू को 1 से इनक्रीस करता है।
- Pre-decrement (–p) expression – यह मौजूदा C++ प्रोगाम में यूजर डिफाइन वेरिएबल कंडीशन एक्सप्रेशन में यूज़ होने से पहले p पैरामीटर की वैल्यू को 1 से डिक्रीस करता है।
- Post-decrement (p–) expression – यह मौजूदा C++ प्रोगाम में यूजर डिफाइन वेरिएबल कंडीशन एक्सप्रेशन में यूज़ होने के बाद p पैरामीटर की वैल्यू को 1 से डिक्रीस करता है।
Pre-increment (++p) operator in C++.
प्री-इन्क्रीमेंट ऑपरेटर यह मौजूदा C++ प्रोगाम में यूजर डिफाइन वेरिएबल कंडीशन एक्सप्रेशन में यूज़ होने से पहले मौजूदा वेरिएबल की करंट वैल्यू को 1 से इनक्रीस कर डिस्प्ले करता है।
Syntax of the pre-increment (++p) operator.
++p;
Example of the pre-increment (++p) operator.
#include <iostream>
using namespace std;
int main() {
int p = 1;
cout << “default Value of p parameter before pre-increment expression – ” << p << endl; // Result is – 1
cout << “default Value of p parameter after pre-increment expression – ” << ++p << endl; // Result is – 2
cout << “Value of p parameter after pre-increment expression – ” << p << endl; // Result is – 2
return 0;
}
explanation of the pre-increment (++a) operator.
- यहाँ C++ प्रोगाम में ++p एक्सप्रेशन पहले p पैरामीटर वेरिएबल की वैल्यू को 2 तक प्री इन्क्रीमेंट करता है, और इसके बाद बढ़ी हुई वैल्यू को डिस्प्ले करता है।
Post-increment (p++) operator in C++.
पोस्ट-इंक्रीमेंट ऑपरेटर यह मौजूदा C++ प्रोगाम में यूजर डिफाइन वेरिएबल कंडीशन एक्सप्रेशन में यूज़ होने के बाद मौजूदा वेरिएबल की करंट वैल्यू को 1 से इनक्रीस कर डिस्प्ले करता है।
Syntax of the post-increment (p++) operator.
p++;
Example of the post-increment (p++) operator.
#include <iostream>
using namespace std;
int main() {
int p =1;
cout << “default Value of p parameter before post-increment expression – ” << p << endl; // Result is – 1
cout << “default Value of p parameter after post-increment expression – ” << p++ << endl; // Result is – 1
cout << “Value of p parameter after post-increment expression – ” << p << endl; // Result is – 2
return 0;
}
explanation of the post-increment (p++) operator.
- यहाँ C++ प्रोगाम में p++ एक्सप्रेशन पहले p पैरामीटर वेरिएबल की मौजूदा वैल्यू (जो पहले 1 है) उस वैल्यू को रिटर्न करता है, और फिर p की वैल्यू को 2 वैल्यू तक इंक्रीमेंट कर डिस्प्ले करता है।
Pre-decrement (–p) operator in C++.
प्री-डिक्रीमेंट ऑपरेटर यह मौजूदा C++ प्रोगाम में यूजर डिफाइन वेरिएबल कंडीशन एक्सप्रेशन में यूज़ होने से पहले मौजूदा वेरिएबल की करंट वैल्यू को डिक्रीस करता है।
Syntax of the pre-decrement (–p) operator.
–p;
Example of the pre-decrement (–p) operator.
#include <iostream>
using namespace std;
int main() {
int p = 2;
cout << “default Value of p parameter before pre-decrement expression – ” << p << endl; // Result is – 2
cout << “default Value of p parameter after pre-decrement expression – ” << –p << endl; // Result is – 1
cout << “Value of p parameter after pre-decrement expression – ” << p << endl; // Result is – 1
return 0;
}
explanation of the pre-decrement (–p) operator.
- यहाँ C++ प्रोगाम में –p एक्सप्रेशन पहले p पैरामीटर वेरिएबल की मौजूदा वैल्यू को 1 से घटाकर कर डिस्प्ले करता है, और फिर डिक्रीमेंट की गई p वेरिएबल की वैल्यू को डिस्प्ले करता है।
Post-decrement (p–) operator in C++.
पोस्ट-डिक्रीमेंट ऑपरेटर यह मौजूदा C++ प्रोगाम में यूजर डिफाइन वेरिएबल कंडीशन एक्सप्रेशन में यूज़ होने के बाद वेरिएबल की करंट वैल्यू को डिक्रीस कर डिस्प्ले करता है।
Syntax of the post-decrement (p–) operator.
p–;
Example of the post-decrement (p–) operator.
#include <iostream>
using namespace std;
int main() {
int p = 2;
cout << “default Value of p parameter before post-decrement expression – ” << p << endl; // Result is – 2
cout << “default Value of p parameter after post-decrement expression – ” << p– << endl; // Result is – 2
cout << “Value of p parameter after post-decrement expression – ” << p << endl; // Result is – 1
return 0;
}
explanation of the post-decrement (p–) operator.
- यहाँ C++ प्रोगाम में p– एक्सप्रेशन पहले p पैरामीटर वेरिएबल की मौजूदा वैल्यू (जो 2 है) उसे डिस्प्ले करता है, और फिर डिक्रीमेंट की गई p वेरिएबल की वैल्यू को डिस्प्ले करता है.
Main Differences Between Pre and Post Operators
| Operator | Increment and Decrement operators Description | Execution of steps | Example |
| ++p | It used to Increments the value of any variable before using it | In this variable value is incremented expression first and then used by system | int q = ++p; |
| p++ | It used to Increments the value of any parameter after using it | In this variable value is used expression first and then incremented then used by system | int q = p++; |
| –p | It used to Decrements the value of user define variable value before using it | In this variable value is decremented first and then used by system | int q = –p; |
| p– | It used to Decrements the value of user define variable value after using it | In this variable value is used first and then decremented | int q = p–; |
When to use pre-increment/decrement vs. post-increment/decrement in a C++ program.
C++ प्रोगाम में प्री-इन्क्रीमेंट (++p) और प्री-डिक्रीमेंट (–p) वेरिएबल ऑपरेटर तब यूज़ किए जाते हैं. जब C++ यूजर को किसी स्पेसिफिक कैलकुलेशन या एक्सप्रेशन में यूज़ करने से पहले यूजर डिफाइन डिक्लेअर मौजूदा वेरिएबल को मॉडिफाई या अपडेट कर डिस्प्ले करने की ज़रूरत होती है।
C++ प्रोगाम में पोस्ट-इन्क्रीमेंट (p++) और पोस्ट-डिक्रीमेंट (p–) ऑपरेटर वेरिएबल का यूज़ सामान्य रूप से तब किया जाता है. जब मौजूदा वेरिएबल में डिफ़ॉल्ट वैल्यू मॉडिफिकेशन से पहले मौजूदा वैल्यू की आवश्यकता होती है।
Example of pre- and post-increment/decrement operators in a loop statement.
C++ में यूजर डिफाइन प्रोग्राम में यूज़ लूप काउंटर वैल्यू को मॉडिफाई करने के लिए मौजूदा प्रोग्राम लूप में इन्क्रीमेंट और डिक्रीमेंट ऑपरेटर को पैरामीटर के साथ लार्ज लेवल पर अप्लाई किया जाता है।
Example of the pre-increment operator in a loop.
#include <iostream>
using namespace std;
int main() {
int p = 0;
while (p < 9 ) {
cout << ++p << ” “; // here pre-increment expression – Increment before using the variable value
} // result – 1 2 3 4 5 6 7 8 9
return 0;
}
explanation of the pre-increment operator in a loop.
- यहाँ इस C++ प्रोगाम में ++p एक्सप्रेशन व्हाइल लूप में प्रिंट होने से पहले p पैरामीटर की वैल्यू को इन्क्रीमेंट कर डिस्प्ले करता है।
Example of the post-increment operator in a loop.
#include <iostream>
using namespace std;
int main() {
int p = 0;
while (p < 11) {
cout << p++ << ” “; // here post-increment expression Use the current value before variable incrementing
} // result – 0 1 2 3 4 5 6 7 8 9 10
return 0;
}
explanation of the post-increment operator in a loop.
- यहाँ इस C++ प्रोगाम में p++ एक्सप्रेशन व्हाइल लूप में इन्क्रीमेंट करने से पहले p पैरामीटर की मौजूदा वैल्यू को यूज़ करता है।
Detail Summary of Increment/Decrement Operators in c++
| Operator | Increment/Decrement Operators Description | Example |
| ++p | Pre-increment expression – in any c++ program it Increments the variable value before it is used | int q = ++p; |
| p++ | Post-increment expression – in any c++ program it Increments the variable value after it is used | int q = p++; |
| –p | Pre-decrement expression – in any c++ program it Decrements the variable value before it is used | int q = –p; |
| p– | Post-decrement expression – in any c++ program it Decrements the variable value after it is used | int q = p–; |
Summary of Increment and Decrement Operators in C++.
- किसी भी C++ प्रोगाम में प्री-इन्क्रीमेंट (++p) और प्री-डिक्रीमेंट (–p) ऑपरेटर कंडीशन एक्सप्रेशन को यूज़ करने से पहले उस वेरिएबल की वैल्यू को मॉडिफाई करते हैं।
- किसी भी C++ प्रोगाम में पोस्ट-इन्क्रीमेंट (p++) और पोस्ट-डिक्रीमेंट (p–) ऑपरेटर कंडीशन एक्सप्रेशन को यूज़ करने के बाद उस वैल्यू को मॉडिफाई या अपडेट करते हैं।
