Solved

randomized

Posted on 1999-01-06
5
202 Views
Last Modified: 2010-04-15
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
Comment
Question by:samuelccs
  • 3
  • 2
5 Comments
 

Author Comment

by:samuelccs
Comment Utility
can you show me some example of  "randomized program" ?
0
 
LVL 2

Accepted Solution

by:
hougaard earned 30 total points
Comment Utility
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
 

Author Comment

by:samuelccs
Comment Utility
do you have any more example about randomized. can you show me some of those xample?
0
 

Author Comment

by:samuelccs
Comment Utility
may i know why you divide random() with 32767. what is 32767
0
 
LVL 2

Expert Comment

by:hougaard
Comment Utility
rand() returns 0 - 32767 - so to get the fraction (0-1) i devide
0

Featured Post

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

This tutorial is posted by Aaron Wojnowski, administrator at SDKExpert.net.  To view more iPhone tutorials, visit www.sdkexpert.net. This is a very simple tutorial on finding the user's current location easily. In this tutorial, you will learn ho…
Windows programmers of the C/C++ variety, how many of you realise that since Window 9x Microsoft has been lying to you about what constitutes Unicode (http://en.wikipedia.org/wiki/Unicode)? They will have you believe that Unicode requires you to use…
The goal of this video is to provide viewers with basic examples to understand recursion in the C programming language.
The goal of this video is to provide viewers with basic examples to understand opening and reading files in the C programming language.

763 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now