ulvis.paste.net

Paste Search Dynamic
Recent pastes
value and its walk and run
  1. #include <stdio.h>
  2. int main () {
  3.  int count;
  4.  int sum;
  5.  double avg;
  6. /* Initialize */
  7.  count = 0;
  8.  int walk[6] = {2,2,2,2,2,3,3};
  9.  int run[6] = {2,1,1,1,1,2,2};
  10.  sum = 0;
  11.  avg = 0.0;
  12. // Loop through to input values
  13.  while (count < 7) {
  14.  printf("Enter a value and its walk and run: \n");
  15.  scanf("%d %d", walk[count], run[count]);
  16.  if (walk[count] >= 0) {
  17.  sum = sum + walk[count];
  18.  sum = sum + run[count];
  19.  count = count + 1;
  20.  }
  21.  else {
  22.  printf("walk and run must be positive\n");
  23.  }
  24.  }
  25.  avg = sum / count;
  26.  printf("average is %lf\n " , avg );
  27.  return 0;
  28. } // end main
Parsed in 0.004 seconds