By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,466 Members | 1,309 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,466 IT Pros & Developers. It's quick & easy.

Generate two random number and multiply

P: n/a
I'm new so i apologize if this is in the wrong spot. I'm also new to
programming in C and i've been searching for quite a while on how to
create a program using C that will generate two random numbers,
multiply them, and ask you for the result. It also needs to have four
responses for both right and wrong answers and should print them
randomly as well. The program should use at least 2 functions. Any
help would be greatly appreciated.

Thanks

Mar 5 '07 #1
Share this Question
Share on Google+
20 Replies


P: n/a
jj**********@hotmail.com wrote:
I'm new so i apologize if this is in the wrong spot. I'm also new to
programming in C and i've been searching for quite a while on how to
create a program using C that will generate two random numbers,
multiply them, and ask you for the result. It also needs to have four
responses for both right and wrong answers and should print them
randomly as well. The program should use at least 2 functions. Any
help would be greatly appreciated.

Thanks
This seems like a homework question. Have you atleast made an attempt.
Attempt a try at the problem and post the code here, however bad it
is.

Hint: To generate pseudo-random integer values, use the rand function.
Before using it, it's recommended to invoke the srand function to
"seed" the pseudo-random number generator. To learn how to use rand
and srand, try looking at your implementation's documentation for the
Standard library. If it's a Unix system, try typing 'man 3 rand' and
'man 3 srand' at the command prompt.

To select a string, from a collection randomly, you can use the same
rand function to get a random number, trim it down to be within the
bounds of your array of strings and use it to index into the array and
extract a random string.

Well, try your hand at it.

Mar 5 '07 #2

P: n/a
At about the time of 3/5/2007 7:23 AM, jj**********@hotmail.com stated
the following:
I'm new so i apologize if this is in the wrong spot. I'm also new to
programming in C and i've been searching for quite a while on how to
create a program using C that will generate two random numbers,
multiply them, and ask you for the result. It also needs to have four
responses for both right and wrong answers and should print them
randomly as well. The program should use at least 2 functions. Any
help would be greatly appreciated.

Thanks
Homework?

Go take a look and rand(3) and srand(3). It's standard C.

http://www.acm.uiuc.edu/webmonkeys/book/c_guide/

--
Daniel Rudy

Email address has been base64 encoded to reduce spam
Decode email address using b64decode or uudecode -m

Why geeks like computers: look chat date touch grep make unzip
strip view finger mount fcsk more fcsk yes spray umount sleep
Mar 5 '07 #3

P: n/a

<jj**********@hotmail.comwrote in message
I'm new so i apologize if this is in the wrong spot. I'm also new to
programming in C and i've been searching for quite a while on how to
create a program using C that will generate two random numbers,
multiply them, and ask you for the result. It also needs to have four
responses for both right and wrong answers and should print them
randomly as well. The program should use at least 2 functions. Any
help would be greatly appreciated.
rand() will generate a random number between 0 and RAND_MAX.
RAND_MAX is usually 32767, which is too high for arithmetic drill.

So get a random number in the range 1 = 100 by taking modulus 100. There are
more accurate ways of doing this, but this should be fine now.

Unfortunately you program will generate exactly the same numbers on each
run. So call srand() with the time from time() to seed the random number
generator.

Having got your random numbers, print them out with a message asking the
user to multiply. Then call scanf() to input the result. Don't forget to
check the return value of scanf() to make sure the user actually entered a
number.

Now you need to check whether the number is correct. If it is, call the
random number generator again and print out a random "well done" message -
you can use a switch - if not, print out a "wrong answer message".
--
Free games and programming goodies.
http://www.personal.leeds.ac.uk/~bgy1mm

Mar 5 '07 #4

P: n/a
rand() will generate arandomnumber between 0 and RAND_MAX.
RAND_MAX is usually 32767, which is too high for arithmetic drill.

So get arandomnumber in the range 1 = 100 by taking modulus 100. There are
more accurate ways of doing this, but this should be fine now.

Unfortunately you program will generate exactly the same numbers on each
run. So call srand() with the time from time() to seed therandomnumber
generator.

Having got yourrandomnumbers, print them out with a message asking the
user tomultiply. Then call scanf() to input the result. Don't forget to
check the return value of scanf() to make sure the user actually entered a
number.

Now you need to check whether the number is correct. If it is, call therandomnumber generator again and print out arandom"well done" message -
you can use a switch - if not, print out a "wrong answer message".

--
Free games and programming goodies.http://www.personal.leeds.ac.uk/~bgy1mm
this is what i have so far, don't laugh, i know it's horrible, but i
wanted to know if i'm going in the right direction... i think i'm lost
and confused
#include <stdlib.h>
#include <math.h>
#include <time.h>
#define num_val 1
int randnum (int k);
int product (void);
#define num1 (randnum)*1
#define num2 (randnum)+1

int main (void)
{
int num1= (randnum),
num2= ((randnum) +2);
int value, right, wrong;

srand (unsigned) time ();

printf ("Type -1 to exit!/n");
printf ("What is the product of %d and %d:/t", num1, num2);
scanf ("%d", &value);
if (value==-1)
printf ("Thanks for Playing, Goodbye!");
else (value == product)
printf ("Correct!");
else if (value!=product)
printf ("Wrong!");
}
return (0);
}
int randNum (int k)
{
int ranNum;
ranNum = 1 + (int) ( (float) k * rand() / ( RAND_MAX % 100 ) );
return (ranNum);
}
int product (int j)
{
int prod;
prod = num1 * num2;
return (prod);
}

Mar 6 '07 #5

P: n/a
On Mar 5, 1:46 pm, "Malcolm McLean" <regniz...@btinternet.comwrote:
<jjmillert...@hotmail.comwrote in message
I'm new so i apologize if this is in the wrong spot. I'm also new to
programming in C and i've been searching for quite a while on how to
create a program using C that willgeneratetworandomnumbers,
multiply them, and ask you for the result. It also needs to have four
responses for both right and wrong answers and should print them
randomly as well. The program should use at least 2 functions. Any
help would be greatly appreciated.

rand() willgeneratearandomnumber between 0 and RAND_MAX.
RAND_MAX is usually 32767, which is too high for arithmetic drill.

So get arandomnumber in the range 1 = 100 by taking modulus 100. There are
more accurate ways of doing this, but this should be fine now.

Unfortunately you program willgenerateexactly the same numbers on each
run. So call srand() with the time from time() to seed therandomnumber
generator.

Having got yourrandomnumbers, print them out with a message asking the
user to multiply. Then call scanf() to input the result. Don't forget to
check the return value of scanf() to make sure the user actually entered a
number.

Now you need to check whether the number is correct. If it is, call therandomnumber generator again and print out arandom"well done" message -
you can use a switch - if not, print out a "wrong answer message".

--
Free games and programming goodies.http://www.personal.leeds.ac.uk/~bgy1mm
ok this is what i have so far, don't laugh, i know it's probably
horrible, but if anyone could help with finishing it i would really
appreciate it

#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <time.h>
#define num_val 1
int randnum (int k);
int product (int j);
#define num1 ((randnum)*1)
#define num2 ((randnum)+1)

int main (void)
{int value;

srand (unsigned) time ();

printf ("Type -1 to exit!/n");
printf ("What is the product of %d and %d:/t", num1, num2);
scanf ("%d", &value);
if (value==-1)
printf ("Thanks for Playing, Goodbye!");
else (value == product)
printf ("Correct!");
else if (value!=product)
printf ("Wrong!");
}
return (0);
}
int randNum (int k)
{
int ranNum;
ranNum = 1 + (int) ( (float) k * rand() / ( RAND_MAX % 100 ) );
return (ranNum);
}
int product (int j)
{
int prod;
prod = num1 * num2;
return (prod);
}

Mar 6 '07 #6

P: n/a
jjmillert...@hotmail.com wrote:
On Mar 5, 1:46 pm, "Malcolm McLean" <regniz...@btinternet.comwrote:
<jjmillert...@hotmail.comwrote in message
I'm new so i apologize if this is in the wrong spot. I'm also new to
programming in C and i've been searching for quite a while on how to
create a program using C that willgeneratetworandomnumbers,
multiply them, and ask you for the result. It also needs to have four
responses for both right and wrong answers and should print them
randomly as well. The program should use at least 2 functions. Any
help would be greatly appreciated.
rand() willgeneratearandomnumber between 0 and RAND_MAX.
RAND_MAX is usually 32767, which is too high for arithmetic drill.

So get arandomnumber in the range 1 = 100 by taking modulus 100. There are
more accurate ways of doing this, but this should be fine now.

Unfortunately you program willgenerateexactly the same numbers on each
run. So call srand() with the time from time() to seed therandomnumber
generator.

Having got yourrandomnumbers, print them out with a message asking the
user to multiply. Then call scanf() to input the result. Don't forget to
check the return value of scanf() to make sure the user actually entered a
number.
ok this is what i have so far, don't laugh, i know it's probably
horrible, but if anyone could help with finishing it i would really
appreciate it

#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <time.h>
#define num_val 1
int randnum (int k);
int product (int j);
#define num1 ((randnum)*1)
#define num2 ((randnum)+1)
Wrong invocation of function randnum. It expects an int parameter,
according to your prototype above, but here you invoke it not only
without a parameter, but also without the parenthesis. A function call
must always have the accompanying parenthesis, even if there are no
arguments.
>
int main (void)
{int value;

srand (unsigned) time ();
srand((unsigned)time(NULL));
printf ("Type -1 to exit!/n");
Newline is '\n', not '/n'. In fact all C escape sequences start with a
'\', like '\t' for tab, '\a' for audible alert etc.
printf ("What is the product of %d and %d:/t", num1, num2);
Likewise '\t' for tab.
scanf ("%d", &value);
scanf is prone to failure. You should always check it's return value
before proceeding.
if (value==-1)
printf ("Thanks for Playing, Goodbye!");
else (value == product)
You mean an else if here, and an else below. Also, again you have to
supply the parenthesis around a function call. product also expects an
argument of type int.
printf ("Correct!");
else if (value!=product)
printf ("Wrong!");
Also always include a newline character at the end of printf strings
or alternatively call fflush(stdout) immediately afterwards, otherwise
output may appear delayed due to buffering.
}
return (0);
Parenthesis is redundant, but harmless.
}
int randNum (int k)
This function is never called in your code. C is case sensitive.
You've named this function randNum, but you invoke it as randnum,
(which is itself incorrect), above. It'll lead to a linkage error,
during compilation.
{
int ranNum;
ranNum = 1 + (int) ( (float) k * rand() / ( RAND_MAX % 100 ) );
Huh? Why so much contortion. Just:

return rand() % 100;

should do.
return (ranNum);
}

int product (int j)
{
int prod;
prod = num1 * num2;
return (prod);
}
Why're you invoking num1 and num2 again? You should use the previous
values. Each call to rand will return different values.

Mar 6 '07 #7

P: n/a
jj**********@hotmail.com wrote:
On Mar 5, 1:46 pm, "Malcolm McLean" <regniz...@btinternet.comwrote:
[ ... ]
create a program using C that willgeneratetworandomnumbers,
multiply them, and ask you for the result. It also needs to have four
responses for both right and wrong answers and should print them
randomly as well. The program should use at least 2 functions. Any
help would be greatly appreciated.
[ ... ]

Here's a short programme that may be similar to what you want:

#include <stdio.h>
#include <stdlib.h>
#include <time.h>

int main(void) {
int n1, n2;
long prd, guess;

srand((unsigned int)time(NULL));

n1 = 1 + (int)(100.0 * (rand() / (RAND_MAX + 1.0)));
n2 = 1 + (int)(100.0 * (rand() / (RAND_MAX + 1.0)));
prd = n1 * n2;

printf("What is the product of %d and %d\?\n"
"[Enter -1 to exit]\n", n1, n2);

if(scanf("%ld", &guess) != 1) {
puts("Incorrect input.");
return EXIT_FAILURE;
}
else if(guess == -1) {
puts("bye.");
}
else if(guess == prd) {
puts("Correct!");
}
else {
puts("Wrong guess.");
}
return 0;
}

Mar 6 '07 #8

P: n/a
On Mar 5, 10:44 pm, "santosh" <santosh....@gmail.comwrote:
jjmillert...@hotmail.com wrote:
On Mar 5, 1:46 pm, "Malcolm McLean" <regniz...@btinternet.comwrote:
<jjmillert...@hotmail.comwrote in message
I'm new so i apologize if this is in the wrong spot. I'm also new to
programming inCand i've been searching for quite a while on how to
create a programusingCthat willgeneratetworandomnumbers,
multiplythem, and ask you for the result. It also needs to have four
responses for both right and wrong answers and should print them
randomly as well. The program should use at least 2 functions. Any
help would be greatly appreciated.
rand() willgeneratearandomnumber between 0 and RAND_MAX.
RAND_MAX is usually 32767, which is too high for arithmetic drill.
So get arandomnumber in the range 1 = 100 by taking modulus 100. There are
more accurate ways of doing this, but this should be fine now.
Unfortunately you program willgenerateexactly the same numbers on each
run. So call srand() with the time from time() to seed therandomnumber
generator.
Having got yourrandomnumbers, print them out with a message asking the
user tomultiply. Then call scanf() to input the result. Don't forget to
check the return value of scanf() to make sure the user actually entered a
number.
ok this is what i have so far, don't laugh, i know it's probably
horrible, but if anyone could help with finishing it i would really
appreciate it
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <time.h>
#define num_val 1
int randnum (int k);
int product (int j);
#define num1 ((randnum)*1)
#define num2 ((randnum)+1)

Wrong invocation of function randnum. It expects an int parameter,
according to your prototype above, but here you invoke it not only
without a parameter, but also without the parenthesis. A function call
must always have the accompanying parenthesis, even if there are no
arguments.
int main (void)
{int value;
srand (unsigned) time ();

srand((unsigned)time(NULL));
printf ("Type -1 to exit!/n");

Newline is '\n', not '/n'. In fact allCescape sequences start with a
'\', like '\t' for tab, '\a' for audible alert etc.
printf ("What is the product of %d and %d:/t", num1, num2);

Likewise '\t' for tab.
scanf ("%d", &value);

scanf is prone to failure. You should always check it's return value
before proceeding.
if (value==-1)
printf ("Thanks for Playing, Goodbye!");
else (value == product)

You mean an else if here, and an else below. Also, again you have to
supply the parenthesis around a function call. product also expects an
argument of type int.
printf ("Correct!");
else if (value!=product)
printf ("Wrong!");

Also always include a newline character at the end of printf strings
or alternatively call fflush(stdout) immediately afterwards, otherwise
output may appear delayed due to buffering.
}
return (0);

Parenthesis is redundant, but harmless.
}
int randNum (int k)

This function is never called in your code.Cis case sensitive.
You've named this function randNum, but you invoke it as randnum,
(which is itself incorrect), above. It'll lead to a linkage error,
during compilation.
{
int ranNum;
ranNum = 1 + (int) ( (float) k * rand() / ( RAND_MAX % 100 ) );

Huh? Why so much contortion. Just:

return rand() % 100;

should do.
return (ranNum);
}
int product (int j)
{
int prod;
prod = num1 * num2;
return (prod);
}

Why're you invoking num1 and num2 again? You should use the previous
values. Each call to rand will return different values.
ok, i'm not sure if i fixed everything you were talking about, but i
hope i did, thank you so much for your help, this is for homework and
my teacher basically just tells us different parts of things but never
really explains how to put anything together and its really irritating
because i'm usually fairly computer literate
int main (void)
{int value,product;
//set and seed rand
srand ((unsigned) time (NULL));
printf ("Type -1 to exit!\n");
printf ("What is the product of %d and %d:\t", num1, num2);
scanf ("%d", &value);
product = ((num1) * (num2))
//if value is -1, end program
if (value!=-1)
printf ("OK, Goodbuy!\n");
else if ((value) == (product))
printf ("Correct!\n");
else ((value)!=(product))
printf ("Wrong!\n");
}
return (0);
}
//first function
int randnumber (int k)
{
int random;
return rand() % 100;
return (random);
}

Mar 6 '07 #9

P: n/a
wow, thats so much cleaner, could you help me put another function
into it so it will have 4 correct answers (eg "Thats right!") and 4
wrong ("sorry try again") i know you probably have better things to
do, but i have to hand it in in 30 minutes, and obviously i don't know
what i'm doing

Mar 6 '07 #10

P: n/a
jj**********@hotmail.com wrote:
On Mar 5, 10:44 pm, "santosh" <santosh....@gmail.comwrote:
jjmillert...@hotmail.com wrote:
On Mar 5, 1:46 pm, "Malcolm McLean" <regniz...@btinternet.comwrote:
<jjmillert...@hotmail.comwrote in message
[ ... ]
create a programusingCthat willgeneratetworandomnumbers,
>multiplythem, and ask you for the result. It also needs to have four
responses for both right and wrong answers and should print them
randomly as well. The program should use at least 2 functions. Any
help would be greatly appreciated.
[ ... ]
ok this is what i have so far, don't laugh, i know it's probably
horrible, but if anyone could help with finishing it i would really
appreciate it
[ ... ]
ok, i'm not sure if i fixed everything you were talking about, but i
hope i did, thank you so much for your help, this is for homework and
my teacher basically just tells us different parts of things but never
really explains how to put anything together and its really irritating
because i'm usually fairly computer literate
int main (void)
{int value,product;
//set and seed rand
srand ((unsigned) time (NULL));
printf ("Type -1 to exit!\n");
printf ("What is the product of %d and %d:\t", num1, num2);
Since you're not terminating your printf string with a newline, call
fflush(stdout) after it.
Additionally, I hope you've fixed your num1 and num2 macros.
scanf ("%d", &value);
product = ((num1) * (num2))
Here's a mistake. Each invocation of the rand function returns
different values. The two invocations above will not return the same
values as the invocations within the printf statement earlier. So, in
effect, you're computing a product to two different integers than what
you presented to the user earlier.
//if value is -1, end program
if (value!=-1)
if(value == -1)
printf ("OK, Goodbuy!\n");
else if ((value) == (product))
printf ("Correct!\n");
else ((value)!=(product))
printf ("Wrong!\n");
}
return (0);
}
//first function
int randnumber (int k)
{
int random;
Don't use the identifier random. There're certain popular non-standard
functions that use that name.
return rand() % 100;
ITYM random = rand() % 100;

But to get even better randomness do:

random = 1 + (int)(100.0 * (rand() / (RAND_MAX + 1.0)));

This uses the higher order bits of the value that rand returns, which
are more random than the lower order bits.
return (random);
Again the parenthesis aren't necessary.
}
Mar 6 '07 #11

P: n/a
jj**********@hotmail.com wrote:
wow, thats so much cleaner, could you help me put another function
into it so it will have 4 correct answers (eg "Thats right!") and 4
wrong ("sorry try again") i know you probably have better things to
do, but i have to hand it in in 30 minutes, and obviously i don't know
what i'm doing
Try this:

#include <stdio.h>
#include <stdlib.h>
#include <time.h>

#define CORRECT 1
#define INCORRECT 0

void print_rand_msg(const int msg_type);

int main(void) {
int n1, n2;
long prd, guess;

srand((unsigned int)time(NULL));

n1 = 1 + (int)(100.0 * (rand() / (RAND_MAX + 1.0)));
n2 = 1 + (int)(100.0 * (rand() / (RAND_MAX + 1.0)));
prd = n1 * n2;

printf("What is the product of %d and %d\?\n"
"[Enter -1 to exit]\n", n1, n2);

if(scanf("%ld", &guess) != 1) {
puts("Incorrect input.");
return EXIT_FAILURE;
}
else if(guess == -1) {
puts("bye.");
}
else if(guess == prd) {
print_rand_msg(CORRECT);
}
else {
print_rand_msg(INCORRECT);
}
return 0;
}

void print_rand_msg(const int type) {
char *correct_msgs[4] = { "Correct", "You're right!", "Perfect!",
"You've hit the nail on the head!" };
char *incorrect_msgs[4] = { "Wrong.", "Bad luck, try again",
"Waaay of target.", "Not even close." };
const int rndidx = 1 + (int)(4.0 * (rand() / (RAND_MAX + 1.0)));

switch (type) {
case CORRECT:
puts(correct_msgs[rndidx]);
break;
case INCORRECT:
puts(incorrect_msgs[rndidx]);
break;
default:
puts("Wrong argument.");
exit(EXIT_FAILURE);
}
return;
}

Mar 6 '07 #12

P: n/a
On Mar 5, 11:58 pm, "santosh" <santosh....@gmail.comwrote:
jjmillert...@hotmail.com wrote:
wow, thats so much cleaner, could you help me put another function
into it so it will have 4 correct answers (eg "Thats right!") and 4
wrong ("sorry try again") i know you probably have better things to
do, but i have to hand it in in 30 minutes, and obviously i don't know
what i'm doing

Try this:

#include <stdio.h>
#include <stdlib.h>
#include <time.h>

#define CORRECT 1
#define INCORRECT 0

void print_rand_msg(const int msg_type);

int main(void) {
int n1, n2;
long prd, guess;

srand((unsigned int)time(NULL));

n1 = 1 + (int)(100.0 * (rand() / (RAND_MAX + 1.0)));
n2 = 1 + (int)(100.0 * (rand() / (RAND_MAX + 1.0)));
prd = n1 * n2;

printf("What is the product of %d and %d\?\n"
"[Enter -1 to exit]\n", n1, n2);

if(scanf("%ld", &guess) != 1) {
puts("Incorrect input.");
return EXIT_FAILURE;
}
else if(guess == -1) {
puts("bye.");
}
else if(guess == prd) {
print_rand_msg(CORRECT);
}
else {
print_rand_msg(INCORRECT);
}
return 0;

}

void print_rand_msg(const int type) {
char *correct_msgs[4] = { "Correct", "You're right!", "Perfect!",
"You've hit the nail on the head!" };
char *incorrect_msgs[4] = { "Wrong.", "Bad luck, try again",
"Waaay of target.", "Not even close." };
const int rndidx = 1 + (int)(4.0 * (rand() / (RAND_MAX + 1.0)));

switch (type) {
case CORRECT:
puts(correct_msgs[rndidx]);
break;
case INCORRECT:
puts(incorrect_msgs[rndidx]);
break;
default:
puts("Wrong argument.");
exit(EXIT_FAILURE);
}
return;

}
thanks so much for your help, i really appreciate it

Mar 6 '07 #13

P: n/a
On 5 Mar 2007 22:05:31 -0800, in comp.lang.c ,
jj**********@hotmail.com wrote:
>On Mar 5, 11:58 pm, "santosh" <santosh....@gmail.comwrote:
>jjmillert...@hotmail.com wrote:
do, but i have to hand it in in 30 minutes, and obviously i don't know
what i'm doing

Try this:
(snip example)
>
thanks so much for your help, i really appreciate it
Make sure you spend the time to understand it, so that when your
teacher asks, you will be able to answer.
--
Mark McIntyre

"Debugging is twice as hard as writing the code in the first place.
Therefore, if you write the code as cleverly as possible, you are,
by definition, not smart enough to debug it."
--Brian Kernighan
Mar 6 '07 #14

P: n/a
Daniel Rudy wrote:
>
At about the time of 3/5/2007 7:23 AM, jj**********@hotmail.com stated
the following:
I'm new so i apologize if this is in the wrong spot. I'm also new to
programming in C and i've been searching for quite a while on how to
create a program using C that will generate two random numbers,
multiply them, and ask you for the result. It also needs to have four
responses for both right and wrong answers and should print them
randomly as well. The program should use at least 2 functions. Any
help would be greatly appreciated.

Thanks

Homework?

Go take a look and rand(3) and srand(3). It's standard C.

http://www.acm.uiuc.edu/webmonkeys/book/c_guide/
What is rand(3) supposed to mean?

--
pete
Mar 11 '07 #15

P: n/a

pete wrote:
Daniel Rudy wrote:

At about the time of 3/5/2007 7:23 AM, jj**********@hotmail.com stated
the following:
I'm new so i apologize if this is in the wrong spot. I'm also new to
programming in C and i've been searching for quite a while on how to
create a program using C that will generate two random numbers,
multiply them, and ask you for the result. It also needs to have four
responses for both right and wrong answers and should print them
randomly as well. The program should use at least 2 functions. Any
help would be greatly appreciated.
>
Thanks
>
Homework?

Go take a look and rand(3) and srand(3). It's standard C.

http://www.acm.uiuc.edu/webmonkeys/book/c_guide/

What is rand(3) supposed to mean?
I think he meant to say man 3 rand.

Mar 12 '07 #16

P: n/a
pete <pf*****@mindspring.comwrites:
Daniel Rudy wrote:
[...]
>Go take a look and rand(3) and srand(3). It's standard C.

http://www.acm.uiuc.edu/webmonkeys/book/c_guide/

What is rand(3) supposed to mean?
<OT>
Under Unix, "rand(3)" refers to the man page for the rand function in
section 3 of the manual; you can use "man 3 rand" or "man -s 3 rand"
to read it.
</OT>

--
Keith Thompson (The_Other_Keith) ks***@mib.org <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <* <http://users.sdsc.edu/~kst>
"We must do something. This is something. Therefore, we must do this."
-- Antony Jay and Jonathan Lynn, "Yes Minister"
Mar 12 '07 #17

P: n/a
pete wrote:
Daniel Rudy wrote:
.... snip ...
>>
Go take a look and rand(3) and srand(3). It's standard C.

http://www.acm.uiuc.edu/webmonkeys/book/c_guide/

What is rand(3) supposed to mean?
It means, on unixy systems, enter "man N topic". Here it would
translate to "man 3 rand".

--
Chuck F (cbfalconer at maineline dot net)
Available for consulting/temporary embedded and systems.
<http://cbfalconer.home.att.net>

--
Posted via a free Usenet account from http://www.teranews.com

Mar 12 '07 #18

P: n/a
CBFalconer wrote:
pete wrote:
>Daniel Rudy wrote:
.... snip ...
>>Go take a look and rand(3) and srand(3). It's standard C.

http://www.acm.uiuc.edu/webmonkeys/book/c_guide/
What is rand(3) supposed to mean?

It means, on unixy systems, enter "man N topic". Here it would
translate to "man 3 rand".
I think it was man -M 3 rand on Solaris 2.7 but the -M is no
longer necessary on Linux systems.

--
Ioan - Ciprian Tandau
tandau _at_ freeshell _dot_ org (hope it's not too late)
(... and that it still works...)
Mar 12 '07 #19

P: n/a
Nelu <sp*******@gmail.comwrites:
CBFalconer wrote:
>pete wrote:
>>Daniel Rudy wrote:
.... snip ...
>>>Go take a look and rand(3) and srand(3). It's standard C.

http://www.acm.uiuc.edu/webmonkeys/book/c_guide/
What is rand(3) supposed to mean?

It means, on unixy systems, enter "man N topic". Here it would
translate to "man 3 rand".

I think it was man -M 3 rand on Solaris 2.7 but the -M is no
longer necessary on Linux systems.
<OT>
Not quite. "man man" for details. (If you don't have the "man"
command, then you don't need to know how it works.)
</OT>

--
Keith Thompson (The_Other_Keith) ks***@mib.org <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <* <http://users.sdsc.edu/~kst>
"We must do something. This is something. Therefore, we must do this."
-- Antony Jay and Jonathan Lynn, "Yes Minister"
Mar 12 '07 #20

P: n/a
Keith Thompson wrote:
Nelu <sp*******@gmail.comwrites:
>CBFalconer wrote:
>>pete wrote:
Daniel Rudy wrote:

.... snip ...
Go take a look and rand(3) and srand(3). It's standard C.
>
http://www.acm.uiuc.edu/webmonkeys/book/c_guide/
What is rand(3) supposed to mean?
It means, on unixy systems, enter "man N topic". Here it would
translate to "man 3 rand".
I think it was man -M 3 rand on Solaris 2.7 but the -M is no
longer necessary on Linux systems.

<OT>
Not quite. "man man" for details. (If you don't have the "man"
command, then you don't need to know how it works.)
</OT>
<OT>
I no longer have access to Solaris :-(, only to Linux. But I seem
to remember that on Solaris you needed to specify the section
number using a switch. It seems it was -s not -M :-). I was
talking about dropping the option in the context of same use on
Linux vs. Solaris man applications, -M has a different meaning on
Linux... but it doesn't matter... it's -s anyway :-).
</OT>

--
Ioan - Ciprian Tandau
tandau _at_ freeshell _dot_ org (hope it's not too late)
(... and that it still works...)
Mar 12 '07 #21

This discussion thread is closed

Replies have been disabled for this discussion.