Help me out please im havving issues.

Write your question here.
Hey guys can you help me with this simple calculator I made
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
  #include <iostream>

using namespace 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
Last edited on
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;
Topic archived. No new replies allowed.