home *** CD-ROM | disk | FTP | other *** search
/ C by Discovery (4th Edition) / C_By_Discovery_4th_Edition.tar / C_By_Discovery_4th_Edition / _DISK_ / ch2 / epp8.c < prev    next >
C/C++ Source or Header  |  2005-06-16  |  1KB  |  39 lines

  1. /*              epp8.c                */
  2.     
  3. /* Include Files */
  4. #include <stdio.h>
  5.  
  6. int main( void )
  7. {
  8.      int  iochar,
  9.      numdigits = 0,
  10.      numlower = 0,
  11.      numupper = 0,
  12.      numwhites = 0;
  13.  
  14.      while ( ( iochar = getchar() ) != EOF ) {
  15.           if ( ( iochar = ' ' ) || ( iochar = '\t' ) || ( iochar = '\n' ) ) {
  16.                numwhites++;
  17.                putchar( iochar );
  18.           }
  19.           else if ( ( '0' <= iochar ) && ( iochar <= '9' ) ) {
  20.                numdigits++;
  21.                putchar( iochar );
  22.           }
  23.           else if ( ( 'a' <=  iochar ) && ( iochar <= 'z' ) ) {
  24.                numlower++;
  25.                putchar( iochar - 32 );
  26.           }
  27.           else if ( ( 'A' <=  iochar ) && ( iochar <= 'Z' ) ) {
  28.                numupper++;
  29.                putchar( iochar );
  30.           }
  31.           else putchar( iochar );
  32.      }
  33.  
  34.      printf( "%d white characters, %d digits, ", numwhites, numdigits );
  35.      printf( "%d lowercase have been converted to", numlower );
  36.      printf( "uppercase and %d uppercase.\n", numupper );
  37.      return 0;
  38. }
  39.