C++ Saved Program: majestic-life

facebook share

Here's the online compiler accompanied with IDE at your service. This is a saved code by one of our users. Try it out or save your own from the IDE page and don't forget to leave a feedback. You can find that at the bottom of the page.

#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()
        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;



Press the execute button or CTRL + enter to run code.