Anyone have any idea?

Oct 16, 2013 at 7:01pm
i'm very new to this...
Does anyone have any idea on how to start this program?
Any help would be appreciated.

Write a program that generates 50 random numbers of type integer ranges from 1 to 1000 and load all the numbers into a C++ vector. The program should then display the largest, the smallest, the sum, and the average values stored in the vector. Sort the vector in ascending order and display all values on screen.

Thanks.
Oct 16, 2013 at 9:01pm
Well ;)
1
2
3
4
5
6
7
8
9
#include<iostream>//to display the values on screan.
#include <cstdlib> // for rand() and srand()
#include <ctime> // for time()
int main()//this starts the program
{
    srand(time(0)); // set initial seed value to system clock
    //...your attampt
    return 0;//this ends the program.
}

have fun ;)
Oct 16, 2013 at 9:28pm
as Chriscpp said

the range of numbers [a , b-1] can be determinated by :
in for loop use:

array[i] = ( rand() % b ) + a ;

code & enjoy :D
Topic archived. No new replies allowed.