Simple Cal

Wrote a Simple Cal in C programing this is output
i8411:~/Documents/Code_Programming/Calc BALL$ ./calc
Result : 0
Enter operator and number :+3
Result : 3
Enter operator and number :-1
Result : 2
Enter operator and number :*4
Result : 8
Enter operator and number :/2
Result : 4
Enter operator and number :q
i8411:~/Documents/Code_Programming/Calc BALL$

If you want a code please read more


This is code
[c]#include

char line[100];
int result;
char operat;
int value;

int main()
{
result = 0;

while(true){
printf("Result : %dn", result);
printf("Enter operator and number :");
fgets(line, sizeof(line),stdin);
sscanf(line, "%c %d", &operat, &value);

if((operat == ‘q’) || (operat == ‘Q’))
break;

if (operat == ‘+’)
{
result += value;
}
else if (operat == ‘-‘)
{
result -= value;
}
else if (operat == ‘*’)
{
result *= value;
}
else if (operat == ‘/’)
{
if (value == 0)
{
printf("Error:Divide by zeron");
}
else{
result /= value;
}
}
else{
printf("Unknow operator ");
}
}
}[/c]

engineerball Written by: