/* displays stars up to 15 per line, demonstrates conio.h, while loops and practicing implementing functions Hawk */ #include // Use #include #include // Don't need it if Sleep() is not needed //********** begin increase void Increase() { int StarsOutNow = 0; int StarsPerLine = 1; while (StarsPerLine < 16) { while (StarsOutNow < StarsPerLine) { StarsOutNow = 0; while (StarsOutNow < StarsPerLine) { cout << "*"; StarsOutNow++; } } cout << endl; StarsPerLine++; Sleep(50); } // end while loop } // *********** end increase function // *********** begin decrease function void Decrease() { int StarsOutNow = 0; int StarsPerLine = 14; while (StarsPerLine > 0) { while (StarsOutNow < StarsPerLine) { StarsOutNow = 0; while (StarsOutNow < StarsPerLine) { cout << "*"; StarsOutNow++; } } cout << endl; StarsOutNow = 0; StarsPerLine--; Sleep(50); } // end while loop } // ********** end decrease function and begin main int main() { cout << "Press any key to start outputting stars, press any key to stop" << endl; getch(); while(!kbhit()) // infinite loop until key pressed { Increase(); Decrease(); } getch(); cout << "Press any key to exit. Good bye." << endl; getch(); return(0); }