Answer to Question #342597 in C++ for tine

Question #342597

Write a program that computes for the average of 5 numbers using a sequence control structure. 


1
Expert's answer
2022-05-18T15:26:01-0400
#include <iostream>
using namespace std;
int main(){
  int nums[5];
  cout<<"Enter numbers:"<<endl;
  cin>>nums[0]>>nums[1]>>nums[2]>>nums[3]>>nums[4];
  cout<< static_cast<float>(nums[0]+nums[1]+nums[2]+nums[3]+nums[4])/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