Facebook
From Kazi Majharul, 1 Month ago, written in Plain Text.
Embed
Download Paste or View Raw
Hits: 104
  1. #include<iostream>
  2. using namespace std;
  3. int main()
  4. {
  5.  int n;
  6.  cout<<"Enter an input (Maximum 100): " ;
  7.  cin>>n;
  8.  cout<<"Enter "<<n<<" number."<<endl;
  9.  
  10.  int Array[100]; //Array declare.
  11.  
  12.  for (int i=0; i<n; i++)
  13.  {
  14.   cin>>Array[i]; //Taking input.
  15.  }
  16.  
  17.  int sum=0;
  18.  
  19.  for(int i; i<n; i++)
  20.  {
  21.   sum=sum+Array[i];
  22.  }
  23.  
  24.    cout<<"Summation of these "<<n<<" number is: "<<sum<<endl;
  25.  
  26.    float Average;
  27.    Average=(float) sum/n ;  //Type casting.
  28.  
  29.    cout<<"Average of these "<<n<<" number is: "<<Average;
  30.  
  31. }
  32.