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