How do I make it that when I divide by 2 numbers(10/2/2) it will give me the right solution. Also how do I make it find the remainder when one number is divided by another.
How would I begin with being able to divide by 2 or more numbers? With if-else statements.
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<stdlib.h>
void main()
{
char operation = 0;
double num1=0.0 ;
double num2=0.0 ;
printf("Enter the calculation\n");
scanf("%f %c %f", &num1, &operation, &num2);
switch (operation) {
case '+':
printf("= %f\n", num1 + num2);
break;
case '-':
printf("= %f\n", num1 - num2);
break;
case '*':
printf("= %f\n", num1*num2);
break;
case '/':
printf("= %f\n", num1 /(double)num2);
break;
case '%':
printf("= %f\n", num1 % (double)num2);
break;
default:
printf("Error!\n");
break;
}
system("pause");
}