Note: rand ( ) % (b-a+1) +a // generate random number between [a, b]
#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;
}
Comments
Leave a comment