/* * @topic Q00715 2/27/2014 integer division and modulo operators * @brief inserting blank lines into the output */ #include <iostream> void pause() { //---------------------------------------------- // prevent window from closing before exiting: //---------------------------------------------- char ch; // ch is a variable that holds a character // curious \n is a "line feed" control character, // it moves the cursor to the next line: std::cout << "\nEnter X to Exit: "; std::cin.ignore( 1, '\n' ); // extract and discard characters std::cin.clear(); // this clears cin state std::cin.get( ch ); // this reads a character from the keyboard, // and pauses the program from before exiting } int main() { int xval = 7; int yval = 4; int zval = ( xval / yval ); // quotient + remainder int mval = ( xval % yval ); // quotient + remainder int idx = 1; for ( ; idx < 25; idx = idx + 1 ) { std::cout << " " << idx; if ( idx % 3 == 0 ) { // on every third line a blank line is inserted std::cout << "\n"; } } pause(); return 0; }