// Arup Guha
// 9/21/2011
// Written in COP 3223H - an illustration of break.

#include <stdio.h>
#include <time.h>

int main() {

    srand(time(0));

    // Get and print the first value.
    int num = rand();
    printf("%d\n", num);

    // Initial values
    int nextnum = 0;
    int numvals = 1;

    // Try to create 10 increasing random numbers.
    while (numvals < 10) {

        int numtimes = 0;
        while (1) {

            // Get the next number.
            nextnum = rand();
            numtimes++;

            // Update if it's bigger than the last.
            if (nextnum > num) {
                printf("%d needed %d tries\n", nextnum, numtimes);
                num = nextnum;
                numvals++;
                break;
            }
          }

          // Avoids the infinite loop.
          if (num == 32767)
              break;
    }

    return 0;
}
