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;
}
#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;
}
Comments
Leave a comment