Divide throw 3
Hello, i need to write a programm which reads in a three digit number, then gets the sum of it (2+3+4), and will check if it is dividable by 3. Input: 234 sum= 9 Output= The number is dividable by 3 with a remainder of 0. #include<iostream> #include<cmath> using namespace std; int main () { bool run {true}; while (run) { long num, counter; double sum {0}; cout<< "Type in three numbers "; cin>> num; if (num>=1000) cout<< "Choosen number has more then three digits!!! will calculate anyway\n"; // hab es nicht hinbekommen das das programm hier dann nochmals von vorne beginnt while (num!=0) { counter=num%10; sum+=counter; num=num/10; } cout<< "\n" <<"The sum of the three digits is "<< sum <<"\n\n"; cout<< sum << "Can the sum of digits be divided by 3? " ; // if (sum % 3) // { // cout<< "yes with a remainder of " << (sum%=3) ; // } char answer; cout<< "Run the Programm again? (y/n): "; cin>> answer; run = answer == 'y'; } return 0; }