SHARE
TWEET

fuck everything

a guest Feb 21st, 2019 57 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <iostream>
  2. #include <conio.h>
  3. #include <cmath>
  4. using namespace std;
  5.  
  6. float standev_f(float arr[], float mean){
  7.    
  8.     float standev=0;
  9.    
  10.     for(int x=0; x<5; x++){
  11.        
  12.         arr[x] = (arr[x] - mean) * (arr[x] - mean);
  13.         standev+=arr[x];
  14.        
  15.     }
  16.    
  17.     standev = sqrt(standev) / 5;
  18.  
  19.     return standev;
  20.    
  21. }
  22.  
  23. float mean_f(float arr[]){
  24.    
  25.     float mean=0;
  26.    
  27.     for(int x=0; x<5; x++){
  28.        
  29.         mean+=arr[x];
  30.        
  31.     }
  32.    
  33.     mean/=5;
  34.    
  35.     return mean;
  36. }
  37.  
  38. void start(){
  39.    
  40.     float arr[5]={0}, mean=0, standev=0;
  41.    
  42.     for(int x=0; x<5; x++){
  43.        
  44.         cout<<"\n\t\tPlease enter integer "<<x+1<<": ";
  45.         cin>>arr[x];
  46.        
  47.     }
  48.    
  49.     mean = mean_f(arr);
  50.     standev = standev_f(arr,mean);
  51.     cout<<"\n\n\t\tMean: "<<mean;
  52.     cout<<"\n\n\t\tStandard Deviation: "<<standev;
  53.    
  54. }
  55.  
  56. int main(){
  57.    
  58.     start();
  59.     getch();
  60.    
  61. }
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
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top