Facebook
From Aninda 210520, 1 Month ago, written in Plain Text.
Embed
Download Paste or View Raw
Hits: 88
  1. #include<iostream>
  2. using namespace std;
  3. int main(){
  4. int array[100];
  5. cout<<"how many data do you want to enter?"<<endl;
  6. int input;
  7. cin>>input;
  8. int a;
  9. for(a=0; a&lt;input; a++)
  10. {
  11.     cin&gt;&gt;array[a];
  12.  }
  13.  for(int b=0; b&lt;input; b++)
  14. { cout&lt;&lt;"Array["<<b<<"]="<<array[b]<<endl;
  15. }
  16. int c;
  17. float sum=0;
  18. for (c=0; c&lt;input; c++)
  19. { sum= sum+ array[c];
  20.  
  21.  }
  22. cout&lt;&lt;"sum of inputs ="<<sum<<endl;
  23. float average;
  24. int d;
  25. average=sum/input;
  26. cout<<"average of your inputs ="<<average<<endl;
  27.  
  28.   return 0;}