I am working on a Basic Calculator and have overall the general idea of what I am doing. I am stuck on two things:
- Trying to put in decimals within the calculator, but I am not sure where the
floatordoublewould go. - Trying to set an integer bounds.
My code is here:
#pragma warning(disable: 4996)
#pragma warning(disable: 6031)
#pragma warning(disable: 6064)
#include <stdio.h>
#include <conio.h>
#include <iostream>
#include <iomanip>
int main()
{ char operand;
int x, y;
//Main Inputs from User
printf("Please Enter in an Operator (+, -, *, /): ");
scanf("%c", &operand);
rewind(stdin);
printf("Enter Two Values\n");
scanf("%d%d", &x, &y);
//If Statements
if (y != 0)
printf("%d / %d = %d\n", x, y, x / y);
else
printf("You can't divide a number by 0\n");
//Switch Case
switch (operand)
{
case '+': printf("\n%d + %d = %d\n",x, y, x + y);
break;
case '-':printf("\n%d - %d = %d\n",x, y, x - y);
break;
case '*':printf("\n%d * %d = %d\n",x, y, x * y);
break;
}
_getch();
return 0;
}```