home *** CD-ROM | disk | FTP | other *** search
/ C by Discovery (4th Edition) / C_By_Discovery_4th_Edition.tar / C_By_Discovery_4th_Edition / _DISK_ / ch4 / prob3.c < prev    next >
C/C++ Source or Header  |  2005-06-16  |  768b  |  26 lines

  1. /*               prob3.c
  2.  *
  3.  *   Synopsis  - Designed to input values into an array 
  4.  *               of three ints and then display the 
  5.  *               contents of that array. Has a bug in it.
  6.  *   Objective - To provide practice debugging a program
  7.  *               with a common mistake.
  8.  */
  9. /* Include Files */
  10. #include <stdio.h>
  11.  
  12. int main( void )
  13. {
  14.      int intarray[3], count;
  15.  
  16.      printf( "intarray  %x,  &count  %x.\n", intarray, &count );
  17.      for ( count = 0; count <= 3; count++ ) {
  18.           printf( "Cell #%d : ", count );
  19.           scanf( "%d", intarray+count );
  20.      }
  21.  
  22.      printf( "The contents of the array are: " );
  23.      for ( count = 0; count <= 3; count++ )
  24.           printf( "%d\n", intarray[count] );
  25.      return 0;
  26. }