So, right now I've been learning function pointers and the code I've written for it is below
#include <stdio.h>
#include <stdlib.h>
void addition(int a, int b) {
printf("%d", a + b);
}
void subtraction(int a, int b) {
printf("%d", a - b);
}
void multiplication(int a, int b) {
printf("%d", a * b);
}
void division(int a, int b) {
printf("%d", a / b);
}
int main() {
void (*functionPTR_ARR[])(int, int) = { addition, subtraction, multiplication, division };
unsigned int ch, a = 15, b = 10;
printf("Enter a Array Number: ");
scanf("%d\n", &ch);
(*functionPTR_ARR[ch])(a, b);
}
When I run the program and give it input, let's say 2, for the multiplication function. It'll run but it won't give the results while running, it will only give them when I stop it. Is there a reason why this is happening?