// ***************************************************************** // Author: Zhixiang Chen // Class: CSCI/CMPE 1170, Spring 2009 // Lab 12: Continue and more about break // Date: January 12, 2009 // Comment: The code here is meant to be revised. // //----------------------------------------------------------------- // // This lab exercise is to practice the continue and break statements. // It's a little tricky to understand continue well // // Compile and run your program. When everything is fine, // print your .cpp file and turn it to me or the TA. // ***************************************************************** #include < iostream > #include #include < string > #include < cstring > #include < cmath> #include #include using namespace std; int main( ) { //variable declarations int number; //var to store an int value int sum, min, max, avg; //vars to store simple statistical info int counter; //a counter for controling the loop int size; //another counter /************************************************************ Part A. continue in a while loop ************************************************************/ cout<<"************** PLay Counter Controled do-while-Loop************/"< "; cin>>counter; //get the counter size = counter; //memory the counter //start the loop while (counter > 0) { cout<<"Enter an interger ==> "; cin>>number; //get a number //here we use a continue to skip odd numbers if (number % 2 ==1) continue; //to skip all statement from here to the end //of the while loop, and start the next iteration //of the loop. sum += number; if (number > max) max = number; if (number < min) min = number; counter--; } cout<<" You entered " << size << " many integers. " < "; cin>>number; //get a number //start the loop for ( ; //initialization ; //event control ) //update { //add the loop body } cout<<" You entered " << counter << " many integers. " <