int add(int *,int *); int main() { int a,b; scanf("%d %d",&a,&b); add(&a,&b); } int add(int *x,int *y) { int sum=*x+* | SoloLearn: Learn to code for FREE!

0

int add(int *,int *); int main() { int a,b; scanf("%d %d",&a,&b); add(&a,&b); } int add(int *x,int *y) { int sum=*x+*

Can anyone explain the mistake in it?

1/17/2020 6:50:35 AM

LIKITHA S

2 Answers

New Answer

+1

LIKITHA S if you want to add two number with pointer to function than righy way is like this #include <stdio.h> int add(int a, int b){ return a+b; } int main() { int c; int (*p)(int,int); p = add; // p = &add; c = p(3,4); // c = (*p)(3,4); printf("c = %d\n",c); printf("%p",p); return 0; }

+1

Your question is missing something.. You can also do this way continuing your code... int add(int *,int *); int main() { int a,b; scanf("%d %d",&a,&b); add(&a,&b); } int add(int *x,int *y) { int sum=*x+*y; printf("%d",sum); return 0; }