-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfunctionpointers.cpp
More file actions
55 lines (38 loc) · 797 Bytes
/
functionpointers.cpp
File metadata and controls
55 lines (38 loc) · 797 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#include <iostream>
using namespace std;
/*
Below consists of various simple functions that return various
data types and accepts various data types as well. This sample
code demonstrates use of function pointers.
adil hussain 04/01/2020
*/
void function1(){
cout<<"hello world"<<endl;
}
int function2(int a, int b, int c){
int sum =a+b+c;
cout<<sum<<endl;
return 0;
}
void function3(int x){
if(x < 10){
cout << "try again"<<endl;
}else{
cout<<"thank you"<<endl;
}
}
int main() {
typedef void (*funcptr)();
funcptr xx=function1;
xx();
typedef int (*funcptr2)(int,int,int);
funcptr2 yy=function2;
yy(20,30,40);
int x;
cout<<"enter a number"<<endl;
cin >> x;
typedef void(*funcptr3)(int);
funcptr3 cc = function3;
cc(x);
return 0;
}