home *** CD-ROM | disk | FTP | other *** search
/ Microsoft Programmer's Library 1.3 / Microsoft-Programers-Library-v1.3.iso / sampcode / qc_prog / chap04 / debug.c < prev    next >
Encoding:
C/C++ Source or Header  |  1988-04-05  |  551 b   |  23 lines

  1.  
  2. /* DEBUG.C -- for practice with debugger */
  3.  
  4. main()
  5. {
  6.     char response;
  7.     int number, max_numbers = 5, count = 0, total = 0;
  8.     float average;
  9.  
  10.     printf("Continue (y/n)? ");
  11.     response = getche();
  12.     while ((response != 'n') && (count < max_numbers))
  13.         printf("\nEnter a number: ");
  14.         scanf("%d", &number);
  15.         total += number;
  16.         printf("Continue (y/n)? ");
  17.         response = getche();
  18.     average = total / count;
  19.     printf("\nTotal is %d\n", total);
  20.     printf("Average is %f\n", average);
  21. }
  22.  
  23.