Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- double sum(double num1, double num2){
- return num1 + num2;
- }
- double sub(double num1, double num2){
- return num1 - num2;
- }
- double mult(double num1, double num2){
- return num1 * num2;
- }
- double div(double num1, double num2){
- return num1 / num2;
- }
- int main(){
- double (*fp[4])(double,double) = { sum, sub, mult, div};
- int op;
- scanf("%d", &op);
- printf("%.2lf\n", fp[op](10, 20));
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement