प्रोग्रामिंग में, ++ ऑपरेटर इंक्रीमेंट ऑपरेटर है जो ऑपरेंड के मूल्य को 1 से बढ़ाता है। हम इस ऑपरेटर का उपयोग करके संख्या a, b संख्या में 1 जोड़कर दो नंबर जोड़ सकते हैं।
उदाहरण,
Input: a = 31 , b = 4 Output: 35
स्पष्टीकरण − 1 से 31 को चार बार जोड़ने पर 31 +1+1+1+1 =35 तक का योग बनता है।
एल्गोरिदम
Input: two integers a and b. Step 1: loop from 0 to b and follow step 2. Step 2: add 1 to b. Step 3: print the value of a.
उदाहरण
#include <iostream>
using namespace std;
int main(){
int x = 324 , y= 76;
cout<<"The sum of "<<x<<" & "<<y;
if(y>0){
for(int i= 0; i<y;i++){
x++;
}
} else {
for(int i= y; i<0;i++){
x--;
}
}
cout<<" is "<<x;
return 0;
} आउटपुट
The sum of 324 & 76 is 400