Answer to Question #349382 in C++ for vince

Question #349382
  1. In the code editor, you are provided with a main() function that asks the user for 2 integers. Then, a function call to a function named, exchangeGift() is made and the addresses of the 2 integers are passed.
  2. This exchangeGift() function hasn't been implemented yet so this is your task. This has the following description:
  3. Return type - void
  4. Name - exchangeGift
  5. Parameters - 2 addresses of 2 integers
  6. Description - swaps the value of the 2 integers and then adds 100 to the 2nd integer (or 2nd parameter)
  7. DO NOT EDIT THE MAIN

Input


1. First integer

2. Second integer

Output


Enter·integer·1:·10
Enter·integer·2:·20
20·110

#include <iostream>

using namespace std;


int main(void) {

  int a, b;


  cout << "Enter integer 1: ";

  cin >> a;


  cout << "Enter integer 2: ";

  cin >> b;


  exchangeGift(&a, &b);


  cout << a << " " << b;


  return 0;

}


1
Expert's answer
2022-06-10T18:34:29-0400
#include <iostream>

using namespace std;

void exchangeGift(int* a, int* b);

int main(void) {

    int a, b;


    cout << "Enter integer 1: ";

    cin >> a;


    cout << "Enter integer 2: ";

    cin >> b;


    exchangeGift(&a, &b);


    cout << a << " " << b;


    return 0;

}

void exchangeGift(int* a, int* b) {
    swap(*a, *b);
    *b += 100;
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS