pranjal1805

Q7

May 15th, 2021
139
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.00 KB | None | 0 0
  1. #include <stdio.h>
  2. #include<math.h>
  3. float deviation(float x[]);
  4. float sum(float x[]);
  5. float mean(float x[]);
  6. int main()
  7. {  
  8.     float a[5];
  9.     printf("bhai number de de plis. UwU \n");
  10.     for(int i=0;i<5;i++)
  11.     {
  12.         scanf("%f", &a[i]);
  13.     }
  14.     printf("ye le bhai tera sum ab maze kar: %f\n", sum(a));
  15.     printf("ye le bhai tera mean ab maze kar: %f\n", mean(a));
  16.     printf("ye le bhai tera deviation ab maze kar: %f\n", deviation(a));
  17.     return 0;
  18. }
  19.  
  20. float deviation(float x[])
  21. {  
  22.     float sum=0,mean=0,dev=0;
  23.    for(int i=0;i<5;i++)
  24.     {
  25.         sum+=x[i];
  26.     }
  27.  
  28.     mean=sum/5;
  29.  
  30.    for (int i = 0; i < 5; ++i)
  31.     {
  32.        dev += pow(x[i] - mean, 2);
  33.     }
  34.    
  35.     return sqrt(dev / 10);
  36. }
  37. float sum(float x[])
  38.  
  39. {
  40.     int k=0;
  41.     for(int i=0;i<5;i++)
  42.     {
  43.        k+=x[i];
  44.     }
  45.     return k;
  46. }
  47.  
  48. float mean(float x[])
  49. {
  50.     float sum=0,mean=0,dev=0;
  51.    for(int i=0;i<5;i++)
  52.     {
  53.         sum+=x[i];
  54.     }
  55.  
  56.     mean=sum/5;
  57.     return mean;
  58. }
Advertisement
Add Comment
Please, Sign In to add comment