All submissions

Add Two Integers Using Void Pointers

Code

#include <stdio.h>

int add_two_void_pointers(void *a, void *b) {
    // Your logic here
    int *aa, *bb;
    aa = (int *) a;
    bb = (int *) b;
    return (*aa + *bb);
}


int main() {
    int x, y;
    scanf("%d %d", &x, &y);

    int result = add_two_void_pointers(&x, &y);
    printf("%d", result);

    return 0;
}

Solving Approach

cast the pointers as pointers to int 

Loading...

Input

10 20

Expected Output

30