2/15/00
COM1100 Winter2000 Yuhong Yin
6
Example 1 -- while loop
nconst int MAXNUMS = 3;
nint main() {
n   int count = MAXNUMS;
n   int total = 0;
n   while ( count >= 1)  {
n     total ++ ;
n     count --;
n   }
n   cout << “Total = “ << total << endl;
n   cout <<”count = “ << count << endl;
n   return 0;
n}
n
Output:
Total = 3
count = 0