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 using cmath lib
#include <stdio.h> #include <cmath> using namespace std; void update(int *a,int *b) { // Complete this function int temp,noAbs; temp = *a; noAbs = temp - (*b); *a = *a + *b; *b = abs(noAbs); } 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; }
+ 0 comments //hope this will help you
include
include
include
include
include
using namespace std;
void update(int *a, int *b){ *a = *a + *b; cout << *a << endl; *a = *a - *b; *b = abs(*a - *b); cout << *b << endl; }
int main() { int a, b; int *x = &a; int *y = &b; scanf ("%d\n %d", &a, &b); (update(x, y)); return 0; }
+ 0 comments void update(int *a,int *b) { // Complete this function
int c = *a + *b ; int d = *b - *a ; *a = c; *b = abs(d);
}
+ 0 comments #include <cmath> #include <cstdio> #include <vector> #include <iostream> #include <algorithm> using namespace std; int main() { int a,b,c; cin >>a>>b; cout<<a+b<<endl; c=abs(a-b); cout<<c<<endl; return 0; }
+ 0 comments #include <stdio.h> void update(int *a,int *b) { // Complete this function int sum = *a + *b; int value = *a - *b; int absValue; if (value < 0){ absValue = -value; } else { absValue = value; } *a = sum; *b = absValue; } 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 1083 Discussions, By:
Please Login in order to post a comment