SHARE
TWEET

Untitled

a guest Oct 23rd, 2019 79 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. nclude <stdio.h>
  2.  
  3. int main() {
  4.     double sum = 0, num = 0;
  5.     long int number = 0;
  6.     do {
  7.         scanf("%ld", &number);
  8.         if (number <= 0) {
  9.             if (num == 0 && number != 0) {
  10.                 printf("no_entries ");
  11.             } else {
  12.                 switch (number) {
  13.                     case 0:
  14.                         printf("\b");
  15.                         return 0;
  16.                     case -1:
  17.                         printf("%.2f ", (double) (sum / num));
  18.                         break;
  19.                     case -2:
  20.                         printf("%.2f ", (double) sum);
  21.                         break;
  22.                 }
  23.             }
  24.         } else {
  25.             sum += number;
  26.             num++;
  27.         }
  28.     } while (number != 0);
  29.     return 0;
  30. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top