Week 6 In-Class Examples
#include <iostream>
using namespace std;

int main (void) {

   int an_integer = 0;

   cout << "Please enter an integer between 0 and 10 :\n";
   cin >> an_integer;

   while (an_integer != 5) {
     cout << "Sorry, you guessed wrong\n";
     cout << "Please enter an integer between 0 and 10 :\n";
     cin >> an_integer;
   }

   cout << "You guessed it\n";

   return 0;

}

#include <iostream>
using namespace std;

int main (void) {

   int an_integer = 0;

   do {
     cout << "Please enter an integer between 0 and 10 :\n";
     cin >> an_integer;
     if (an_integer != 5) {
       cout << "You guessed wrong\n";
       cout << "Please try again\n";
     }
   }
   while (an_integer != 5);

   cout << "You guessed it\n";

   return 0;

}

#include <iostream>
using namespace std;

int main (void) {

   int loop_ctr;

   for (loop_ctr = 0; loop_ctr < 10; loop_ctr++) {
     cout << loop_ctr << endl;
   }

   cout << "After the loop, loop_ctr is " << loop_ctr << endl;
   return 0;

}

#include <iostream>
using namespace std;

int main (void) {

   int outer_ctr;
   int inner_ctr;

   for (outer_ctr = 0; outer_ctr < 5; outer_ctr++) {
     for (inner_ctr = 0; inner_ctr < 15; inner_ctr++) {
       cout << "*";
     }
     cout << endl;
   }

   return 0;

}

#include <iostream>
#include <iomanip>
using namespace std;

int main(void)
{
    char first_init = 'a';

    cout << "|" << first_init << "|" << endl;

    cout << setw(5);
    cout << "|" << first_init << "|" << endl;

    cout << "|" << setw(5) << first_init << "|" << endl;

    return 0;
}