Advertisement
mustahidhasan

summation, average, divisible by 5, 8 & both

Feb 20th, 2019
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.72 KB | None | 0 0
  1. #include<stdio.h>
  2. #include<math.h>
  3.  
  4. int main()
  5. {
  6.  
  7.  
  8.     int n, i;
  9.     double average, summation = 0;
  10.     scanf("%d", &n);
  11.  
  12.     for(i = 1; i <= n; i++)
  13.     {
  14.         summation += i;//summation
  15.         average = summation / n;// average
  16.  
  17.     }
  18.     printf("summation = %.2lf\n", summation);
  19.     printf("Average = %.2lf\n", average);
  20.  
  21.     for(i = 1; i <= n; i++)
  22.     {
  23.         if(i % 5 == 0  && i % 8 == 0)
  24.         {
  25.             printf("%d “Poopaye\n", i);// divisible by 5
  26.  
  27.         }else{
  28.             if(i %5 == 0){
  29.                 printf("%d Bakayarou\n", i);
  30.             }
  31.             else if(i % 8 == 0){
  32.                 printf("%d Bananonina\n", i);
  33.             }
  34.         }
  35.     }
  36.  
  37.     return 0;
  38. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement