#include <stdio.h>
int main(void)
{
unsigned int a, b, compType;
printf("Input two positive numbers separated by space:");
scanf("%u %u", &a, &b);
do{
printf("Input computation type\n");
printf("1 - product\n");
printf("2 - sum\n");
printf("3 - modulus\n");
scanf("%u", &compType);
} while (compType < 1 || compType > 3);
switch (compType) {
case 1: {
printf("Product equals: %u\n", a*b);
break;
}
case 2: {
printf("Sum equals: %u\n", a+b);
break;
}
case 3: {
if (!b) {
printf("Modulus cannot be computed since the divisor equals to zero.\n");
}
else {
printf("Modulus equals: %u\n", a % b);
}
break;
}
}
return 0;
}
Comments