#include <iostream>
using namespace std;
int myFunction1(int x)
{
return x + 10;
}
int myFunction2(int x)
{
return x * 10;
}
int execFunction(int(*function)(int), int x)
{
return function(x);
}
int main()
{
int y = execFunction( myFunction1, 10 );
cout << y << "\n";
y = execFunction( myFunction2, 10 );
cout << y << "\n";
return 0;
}
OUTPUT:
using namespace std;
int myFunction1(int x)
{
return x + 10;
}
int myFunction2(int x)
{
return x * 10;
}
int execFunction(int(*function)(int), int x)
{
return function(x);
}
int main()
{
int y = execFunction( myFunction1, 10 );
cout << y << "\n";
y = execFunction( myFunction2, 10 );
cout << y << "\n";
return 0;
}
OUTPUT:
No comments:
Post a Comment