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.
  • HackerRank Home

    HackerRank

  • |
  • Prepare
  • Certify
  • Compete
  • Hiring developers?
  1. Prepare
  2. C++
  3. Introduction
  4. Pointer
  5. Discussions

Pointer

Problem
Submissions
Leaderboard
Discussions
Editorial

Sort 1027 Discussions, By:

recency

Please Login in order to post a comment

  • saimoom1362
    6 hours ago+ 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|
    Permalink
  • shashwatsaxena21
    13 hours ago+ 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|
    Permalink
  • aryanganesh_aiml
    4 days ago+ 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|
    Permalink
  • aryanganesh_aiml
    4 days ago+ 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|
    Permalink
  • kayumkhankks2004
    1 week ago+ 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;
    

    }

    0|
    Permalink
Load more conversations

Need Help?


View editorial
View top submissions
  • Blog
  • Scoring
  • Environment
  • FAQ
  • About Us
  • Support
  • Careers
  • Terms Of Service
  • Privacy Policy