Hi so I made a program using if statements, but when I put 64 as the input it does include all of the correct input except for the last part "Not divisible!" It shows up every time! I really don't know how to fix the problem anyone please care to look over my code and help me. I am new to c++. Please explain nicely, it would help me so much.
THANK YOU!!
#include <iostream>
using namespace std;
int main()
{
int num;
cout << "Please enter a number\n";
cin >> num;
if (num % 2 == 0)
{
cout << "Divisible by 2!\n";
}
else if (num % 3 == 0)
{
cout << "Divisible by 3!\n";
}
if (num % 4 == 0)
{
cout << "Divisible by 4!\n";
}
if (num % 5 == 0)
{
cout << "Divisible by 5!\n";
}
if (num % 6 == 0)
{
cout << "Divisible by 6!\n";
}
if (num % 7 == 0)
{
cout << "Divisible by 7!\n";
}
if (num % 8 == 0)
{
cout << "Divisible by 8!\n";
}
if (num % 9 == 0)
{
cout << "Divisible by 9!\n";
}
else
{
cout << "Sorry not divisible by anything!!\n";
}
}