Write c++ code to display avarage of all the element of array (hint [I] =4*I+1 and size of array=5)
#include <iostream>
using namespace std;
int main(){
float array[5], sum = 0;
cout<<"Enter the five elements of the array;\n";
for(int i = 0; i < 5; i++){
cin>>array[i];
sum += array[i];
}
cout<<"\nThe average of all the elements of the array is "<<sum / 5;
return 0;
}
Comments
Leave a comment