Help solving a math problem

Posted on 1998-12-10
Medium Priority
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.
Question by:sadorsky
  • 2

Author Comment

ID: 1255032
Edited text of question
LVL 51

Accepted Solution

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

Expert Comment

ID: 1255034
try this

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


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

Author Comment

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

Featured Post

A proven path to a career in data science

At Springboard, we know how to get you a job in data science. With Springboard’s Data Science Career Track, you’ll master data science  with a curriculum built by industry experts. You’ll work on real projects, and get 1-on-1 mentorship from a data scientist.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

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…
This is a short and sweet, but (hopefully) to the point article. There seems to be some fundamental misunderstanding about the function prototype for the "main" function in C and C++, more specifically what type this function should return. I see so…
The goal of this video is to provide viewers with basic examples to understand and use pointers 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.

600 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