[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now

x
?
Solved

randomized

Posted on 1999-01-06
5
Medium Priority
?
210 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
5 Comments
 

Author Comment

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

Accepted Solution

by:
hougaard earned 90 total points
ID: 1255579
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
ID: 1255580
do you have any more example about randomized. can you show me some of those xample?
0
 

Author Comment

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

Expert Comment

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

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Have you thought about creating an iPhone application (app), but didn't even know where to get started? Here's how: ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ Important pre-programming comments: I’ve never tri…
Summary: This tutorial covers some basics of pointer, pointer arithmetic and function pointer. What is a pointer: A pointer is a variable which holds an address. This address might be address of another variable/address of devices/address of fu…
The goal of this video is to provide viewers with basic examples to understand and use structures in the C programming language.
The goal of this video is to provide viewers with basic examples to understand and use conditional statements in the C programming language.

656 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