Division by zero problem

Hello guys..I'm working on a program which determine if numbers divided have remainders or not.
If they have remainders it prints out "Arcanum!" If they don't it prints out the answer.
But I'm having a problem...the program should also print "Arcanum" if the second input is 0.
I've tried to but I keep not getting it right
ANY HELP WILL DO

#include<iostream>
using namespace std;
int main()
{ int a,b,div;
cout <<"Enter value of a:" <<endl;
cin >> a ;
cout << "Enter value of b:" <<endl;
cin >> b ;
div= a/b;
if (b==0)
cout << "Arcanum!";
else if (a%b == 0)
cout << div ;
else
cout << "Arcanum!";
}
Dividing by zero is bad. Let's not do that.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
#include<iostream>
using namespace std;
int main()
{
  int a,b,div;
  cout <<"Enter value of a:" <<endl;
  cin >> a ;
  cout << "Enter value of b:" <<endl;
  cin >> b ;
  if (b==0)
  {
    cout << "Arcanum!";
  }
  else if (a%b == 0)
  {
    cout << a/b;
  }
  else
  {
    cout << "Arcanum!";
  }
} 
Thanks
Topic archived. No new replies allowed.