We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
- Prepare
- C++
- Introduction
- Pointer
- Discussions
Pointer
Pointer
+ 0 comments C++20:
#include <iostream> using namespace std; void update(int *a, int *b) { int c, d; c = *a + *b; // arithmetic operation according to challange d = abs(*a - *b); // arithmetic operation according to challange *a = c; *b = d; } int main() { int a, b; int *pa = &a, *pb = &b; cin >> a >> b; update(pa, pb); cout << a << endl; cout << b << endl; return 0; }
+ 0 comments include
include
include
include
include
- using namespace std;
- int main() {
- int *a,*b;
- int c,d;
- cin >> c;
- cin >> d;
- *a = c;
- *b = d;
- int a0 = *a + *b;
- int b0 = *a - *b;
- cout << a0 << endl;
- cout << abs(b0) << endl;
- return 0;
- } *
+ 0 comments include
include
using namespace std;
void update(int a,int b) { // Complete this function int c=a+b; int d; if(a>b){ d=a-b; }else{ d=b-a; } cout<
int main() { int a, b; cin>>a>>b; update(a,b); return 0; }
+ 0 comments include
include
using namespace std;
void update(int a,int b) { // Complete this function int c=a+b; int d; if(a>b){ d=a-b; }else{ d=b-a; } cout<
int main() { int a, b; cin>>a>>b; update(a,b); return 0; }
+ 1 comment include
include
void update(int *a,int *b) { int c = *a + *b; *b = abs(*a - *b); *a = c;
}
int main() { int a, b; int *pa = &a, *pb = &b;
scanf("%d %d", &a, &b); update(pa, pb); printf("%d\n%d", a, b); return 0;
}
Load more conversations
Sort 1027 Discussions, By:
Please Login in order to post a comment