Attachment '8.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   printf( "Enter %d values:\n", n );
   9   scanf( "%f", &x );
  10   min = x;
  11   sum = x;
  12   
  13   while (n>1) {
  14       scanf( "%f", &x );
  15       if (x < min)
  16         min = x;
  17       sum = sum + x;
  18       n=n-1;
  19   }
  20   printf( "min = %1.3f\nsum = %1.3f\n", min, sum );
  21     
  22   return 0;
  23 }

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.