Last active
July 1, 2022 06:34
-
-
Save ox1111/d110a35a9f56875c388d8adfd34a59be to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
아들 교육 자료 | |
*/ | |
#include <stdio.h> | |
void add(int a, int b) | |
{ | |
printf("Addition is %d\n", a+b); | |
} | |
void subtract(int a, int b) | |
{ | |
printf("Subtraction is %d\n", a-b); | |
} | |
void multiply(int a, int b) | |
{ | |
printf("Multiplication is %d\n", a*b); | |
} | |
int main() | |
{ | |
// fun_ptr_arr is an array of function pointers | |
void (*fun_ptr_arr[])(int, int) = {add, subtract, multiply}; | |
unsigned int ch, a = 15, b = 10; | |
printf("Enter Choice: 0 for add, 1 for subtract and 2 " | |
"for multiply\n"); | |
scanf("%d", &ch); | |
if (ch > 2) return 0; | |
(*fun_ptr_arr[ch])(a, b); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment