Try
#include <stdio.h>
#include <math.h>
#include <assert.h>
int good_operator(char op);
double operation(double num1 ,char op, double num2);
int main()
{
const double EPSILON = 0.001;
printf("Welcome to Basic Calculator---Made by Cevik Cukurova\n");
int cont;
do
{
double num1,num2, result, intpart;
char op;
printf("Please enter the operation.\n ");
scanf("%lf",&num1);
scanf("%c",&op);
scanf("%lf",&num2);
if ( ! good_operator(op) )
{
printf("Error! Something wrong about operator.\n");
}
else
{
result = operation(num1, op, num2);
printf("result = ");
if ( modf(result, &intpart) > EPSILON )
{
printf("%g\n", result);
}
else
{
printf("%d\n", (int)intpart);
}
}
printf("\n Press 1 to enter another operation.\n");
scanf("%d",&cont);
} while (cont ==1);
return 0;
}
int good_operator(char op)
{
return (op == '+' || op == '-' || op == '*' || op == '/');
}
double operation(double num1 ,char op, double num2)
{
double result;
if (op == '+')
{
result = num1+num2;
}
else if (op == '-')
{
result = num1-num2;
}
else if (op == '*')
{
result = num1*num2;
}
else if( op =='/')
{
result = num1/num2;
}
else
{
assert(0);
}
return result;
}