Answer to Question #188114 in C++ for Fuad mudsr

Question #188114

Write c++ code to display avarage of all the element of array (hint [I] =4*I+1 and size of array=5)


1
Expert's answer
2021-05-02T06:07:15-0400
#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;
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS