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?

17th Jan 2020, 6:50 AM
LIKITHA S
LIKITHA S - avatar
2 Respostas
+ 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; }
17th Jan 2020, 6:57 AM
DishaAhuja
DishaAhuja - avatar
+ 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; }
17th Jan 2020, 11:22 AM
Jayakrishna 🇮🇳