Results 1 to 14 of 14

Thread: Finding the largest number from the rand()!.:Resolved:.

Threaded View

  1. #1

    Thread Starter
    Hyperactive Member voidflux's Avatar
    Join Date
    Jun 2003
    Location
    Brockway, PA
    Posts
    290

    Question Finding the largest number from the rand()!.:Resolved:.

    Hello everyone!
    I have a slight problem!
    I'm suppose to generate 80 random numbers, then I need to find the sum of those random numbers, and the max of the random numbers! Here is my code
    Code:
    #include <iostream>
    #include <cstdlib>
    
    int main()
    {
    	int sum = 0;
    	int first, max;
    	for(int i = 1; i <=80; i++)
    	{
    		cout << 10 + (rand() % 10) << endl;
    		sum = sum + (10 + (rand()%10));
    		
    		
    		
    	}
    	cout <<"The sum is : " << sum << endl;
    	return 0;
    }
    THis finds the sum of the 80 random integers, but how would I get to compare the random integers?
    ANy ideas?
    Thanks!
    Last edited by voidflux; Oct 16th, 2003 at 05:29 PM.
    C¤ry Sanchez
    Computer Science/Engineering
    @ Penn State
    IBM.zSeries Intern
    Mandriva 2007

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width