#include <iostream>
usingnamespace std;
int main()
{
cout << "Welcome to Tyler's Intiger calculator \n";
cout << " Type 1 To Add \n Type 2 to Subtract \n Type 3 to Multiply \n Type 4 to Divide \n";
int a;
int x;
int y;
cin >> a;
cout << "Type first Intiger";
cin >> x;
cout << "Type second Intiger";
cin >> y;
if (a=1) {
cout << x + y;
}
if (a=2) {
cout << x - y;
}
if (a=3) {
cout << x * y;
}
if (a=4) {
cout << x / y;
cout << "remainder" << x%y;
}
return 0;
}
The problem is when you go to divide, the answer is always incorrect.
I understand its not supposed to give me a decimal answer, but it was my knoledge that it would tell me 3 when I do 10 /3 instead of 112324.
Checked back and none of them work. I messed it up please help
x and y are both integers, so dividing them yields an integer. You'll need to cast one of them to a floating point type so floating point division is performed: cout << static_cast<float>(x)/y;