Answer to Question #209338 in C++ for Abende

Question #209338

Write a program to generate 15 random values between 50 and 90? Then find the average. 

           Note: rand ( ) % (b-a+1) +a // generate random number between [a, b]


1
Expert's answer
2021-06-21T15:44:46-0400
#include <iostream>


using namespace std;


int main()
{
    int num [15];
    int sum =0;
    for (int i=1;i<=15;i++){
        num[i]= rand ( ) % (90-50+1) + 50; 
        sum+=num[i];
        cout<<num[i]<<"\t";
    }
    cout<<"\nAverage: "<<sum/15;
    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