Write a program that computes for the average of 5 numbers using a sequence control structure.Â
#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;
}
Comments
Leave a comment