mardi 6 août 2019

How to solve this error of function pointer?

In a program a pointer is declared to function (p) which initialized to function (add)

i tried to read all the concepts related to function pointer. But i couldn't solve it Please help me to solve this program with out any errors.

#include <stdio.h>
#include <iostream>
using namespace std;

int add(int n1, int n2) 
{
    return n1 + n2;
}
int *functocall(int,int);
int caller(int n1, int n2, int(*functocall)(int, int))
{
return (*functocall)(n1, n2);
}

int main() 
{
int a, b, c;
cin >> b >> c;

int (*p)(int,int)=&add;
a=caller(b,c,(*functocall)(b,c));
printf("%d",a);

return 0;
}

If the input is 20 70 Output must be 90

Aucun commentaire:

Enregistrer un commentaire