Moving to a while loop if not divisible by 5 in c++ -
i writing program class user inputs number checked number, checked see if divisible 5 , if 2 satisfied, number used while loop. clarify, if number , divisible 5 code runs, if , divisible 2 code runs. first set of code needs in loop , second (divisible 2) needs in while loop.
i stuck on taking cin , using in second set of code, first set wants manipulate first.
any figuring out great!
code:
#include <iostream> #include <string> #include <fstream> #include <iomanip> using namespace std; int main () { system ("color f0"); int number = 0, countif = 0,countwhile = 0, i=0; cout << "please enter positive integer or 0 quit: "; cin >> number; cin.ignore(); if (number < 0 || number%2 != 0) cout << "error: integer entered either not positive or zero. try again." << endl; //else if (number%5 || (number%2) = 0) (number%5; countif < number; countif +=5) { = number / 10; += countif; cout << << " "; } cin.ignore(); while (countwhile <= && i%2) { int x = 0; cout << x << " "; x += 2; } system ("pause"); return 0; }
i'm looking @ original else if statement
else if (number%5 || (number%2) = 0)
what wanted here instead
else if (number%5 == 0 && number%2 == 0)
and execute code in else if block.
Comments
Post a Comment