what did I do wrong? everything worked fine but my
else {
cout << "no, it is not divisible by 9" << endl;
is being ignored and I can't get it on output.
#include <iostream>
usingnamespace std;
int main()
{
int n, s=0;
cout << "Enter a positive integer between 1 and 1000: ";
cin >> n;
if(n>1000){
cout << "please enter between 1 and 1000" << endl;
return 0;
}
else {
while (n != 0) {
s = s + n % 10;
n = n / 10;
}
for (int i = 1; i <= 1; ++i) {
if (n % 9 == 0){
cout << "yes, it is divisible by 9 and the sum is " <<s<< endl;
}
else {
cout << "no, it is not divisible by 9" << endl;
}
}
}
return 0;
}