initial import
[staff/goc4/2018bti7061.git] / c-4-pointers / examples / c-pointers / functions.c
1 #include <stdio.h>
2
3 void printA(int i){
4 printf("AAAA %i\n",i);
5 }
6 void printB(int i){
7 printf("BBBB %i\n",i);
8 }
9
10 void printSquare(int i, void (*pf)(int a)){
11 int square = i*i;
12 (*pf)(square);
13
14 }
15
16 int main(){
17 int val;
18 puts("type a number");
19 scanf(" %d",&val);
20 if((val%2)==0){
21 printSquare(val,printA);
22 }
23 else{
24 printSquare(val,printB);
25 }
26 }