#Calculator help

4 messages · Page 1 of 1 (latest)

spark dagger
#

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 float or double would 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;
}```
sterile valveBOT
#

When your question is answered use !solved to mark the question as resolved.

Remember to ask specific questions, provide necessary details, and reduce your question to its simplest form. For tips on how to ask a good question run !howto ask.

spark dagger
#

Need some assistance on:
Trying to put in decimals within the calculator, but I am not sure where the float or double would go.
Trying to set an integer bounds.

sterile valveBOT
#

This question thread is being automatically closed. If your question is not answered feel free to bump the post or re-ask. Take a look at !howto ask for tips on improving your question.