app/site-content/proposals/2009/08/06/c___.c
author Madhusudan.C.S <madhusudancs@gmail.com>
Fri, 07 Aug 2009 01:03:56 +0530
changeset 12 aac4944aca52
parent 8 294ff7ac9cb6
permissions -rwxr-xr-x
With ACL registers
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
8
294ff7ac9cb6 Added new set of files.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
     1
#include <stdio.h>
294ff7ac9cb6 Added new set of files.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
     2
294ff7ac9cb6 Added new set of files.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
     3
main()
294ff7ac9cb6 Added new set of files.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
     4
{
294ff7ac9cb6 Added new set of files.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
     5
294ff7ac9cb6 Added new set of files.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
     6
  int n, count = 1;
294ff7ac9cb6 Added new set of files.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
     7
  float x, sum = 0,average;
294ff7ac9cb6 Added new set of files.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
     8
  do {
294ff7ac9cb6 Added new set of files.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
     9
    printf("how many numbers? ");
294ff7ac9cb6 Added new set of files.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    10
    scanf("%d", &n);
294ff7ac9cb6 Added new set of files.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    11
    sum = 0;
294ff7ac9cb6 Added new set of files.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    12
    count = 1;
294ff7ac9cb6 Added new set of files.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    13
    while (count <= n)   {
294ff7ac9cb6 Added new set of files.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    14
      printf("x = ");
294ff7ac9cb6 Added new set of files.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    15
      printf("\n(to end program, enter 0 for x): ");
294ff7ac9cb6 Added new set of files.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    16
      scanf("%f", &x);
294ff7ac9cb6 Added new set of files.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    17
      if (x == 0) 
294ff7ac9cb6 Added new set of files.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    18
        break;
294ff7ac9cb6 Added new set of files.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    19
      sum += x;
294ff7ac9cb6 Added new set of files.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    20
      ++count;
294ff7ac9cb6 Added new set of files.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    21
    }
294ff7ac9cb6 Added new set of files.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    22
    average = sum/n;
294ff7ac9cb6 Added new set of files.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    23
    printf("\nthe average is %f\n", average);
294ff7ac9cb6 Added new set of files.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    24
  } while (x != 0); 
294ff7ac9cb6 Added new set of files.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    25
}
294ff7ac9cb6 Added new set of files.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    26
294ff7ac9cb6 Added new set of files.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    27