Reputation: 3
Can we add two numbers using pointers but without using any variable like a,b? I mean, generally, we take two variables and store it in pointer... but is it possible to the numbers without taking variable or can we take pointer variable?
Upvotes: 0
Views: 86
Reputation: 3219
Simple answer :
int *a = (int *)malloc(sizeof(int));
*a = 10;
int *b = (int *)malloc(sizeof(int));
*b = 20;
printf("%ld + %ld = %ld\n", *a , *b , *a + *b);
Upvotes: 2