Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Help solving a math problem

Posted on 1998-12-10
4
Medium Priority
?
173 Views
Last Modified: 2010-04-15
I am writing a program and part of it I need to:
a number is queried (from 1 - 17)lets call it numb.
i need to generate random numbers in the amount of numb.
ex: if numb is 4 i need to generate four seperate random numbers and add them together.
if someone can show me a easy way to do this it would be appreciated.
P.S. numb will be different everytime the program is run.
0
Comment
Question by:sadorsky
[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
  • 2
4 Comments
 

Author Comment

by:sadorsky
ID: 1255032
Edited text of question
0
 
LVL 51

Accepted Solution

by:
ahoffmann earned 150 total points
ID: 1255033
int i=0;
int r=random();
int numb=(r%10)+(r%7)+1;
if(rumb==4)while(i++<5)r+=random();
printf("%d:%d",numb, r);
0
 
LVL 10

Expert Comment

by:rbr
ID: 1255034
try this

unsigned long randomadd(int numb)
{
unsigned long together;
int i;

together=0;

for (i=0;i<numb;i++)
      together += rand();
return (together);
}
0
 

Author Comment

by:sadorsky
ID: 1255035
Thanks I'll give it a try ...
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

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

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 and use structures in the C programming language.
The goal of this video is to provide viewers with basic examples to understand how to use strings and some functions related to them in the C programming language.

688 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