Question

Write a function called addOne that adds 1 to its integer reference parameter. The function returns...

Write a function called addOne that adds 1 to its integer reference parameter. The function returns nothing, but change the value of the reference parameter permanently. And write the call statement, outside of the function, which shows using a variable (you give it a name) as the argument.

0 0
Add a comment Improve this question Transcribed image text
Answer #1
#include <iostream>

using namespace std;

void addOne(int &n){
   n = n + 1;
}

int main(){
   int n = 5;
   addOne(n);
   cout<<"n = "<<n<<endl;
   return 0;
}
  

n = 6

Add a comment
Know the answer?
Add Answer to:
Write a function called addOne that adds 1 to its integer reference parameter. The function returns...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT