• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 211
  • Last Modified:

randomized

can you write me a program how to show the sum of 100 randomized number which 1) between 1000 and 5000
                        2) between 5001 and 9999
0
samuelccs
Asked:
samuelccs
  • 3
  • 2
1 Solution
 
samuelccsAuthor Commented:
can you show me some example of  "randomized program" ?
0
 
hougaardCommented:
void main()
{
  int i;
  double r;
  double rsum1 = 0;
  double rsum2 = 0;

  for (i = 0;i <= 100; i++)
  {
    rsum1 += (4000.0 * (rand() / 32767.0)) + 1000.0 ;
    rsum2 += (4998.0 * (rand() / 32767.0)) + 5001.0 ;
  }
}

0
 
samuelccsAuthor Commented:
do you have any more example about randomized. can you show me some of those xample?
0
 
samuelccsAuthor Commented:
may i know why you divide random() with 32767. what is 32767
0
 
hougaardCommented:
rand() returns 0 - 32767 - so to get the fraction (0-1) i devide
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now