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
Medium Priority
173 Views
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
[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
• 2

Author Comment

ID: 1255032
Edited text of question
0

LVL 51

Accepted Solution

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

ID: 1255034
try this

{
unsigned long together;
int i;

together=0;

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

Author Comment

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

## Featured Post

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.
###### Suggested Courses
Course of the Month5 days, 20 hours left to enroll