Attachment '8.1.1.c'

Download

   1 #include <stdio.h>
   2 int main( int argc, char **argv ) {
   3   int n;
   4   float x, min, sum;
   5   
   6   /* printf( "Enter n > 0: " );
   7   /* scanf( "%d", &n ); /* read n */
   8   
   9   printf( "Enter values:\n" ); 
  10 
  11   scanf( "%f", &x );
  12   min = x;
  13   sum = x;
  14   n = 1;
  15   
  16   scanf( "%f", &x );
  17   while (x != 0.0) {
  18       if (x < min)
  19         min = x;
  20       sum = sum + x;
  21       n=n+1;
  22       scanf( "%f", &x );
  23   }
  24   printf( "n = %d\n", n );
  25   printf( "min = %1.3f\nsum = %1.3f\n", min, sum );
  26     
  27   return 0;
  28 }

Attached Files

To refer to attachments on a page, use attachment:filename, as shown below in the list of files. Do NOT use the URL of the [get] link, since this is subject to change and can break easily.

You are not allowed to attach a file to this page.