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?
2 Réponses
+ 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;
}