[Subject Prev][Subject Next][Thread Prev][Thread Next][Subject Index][Thread Index]
Re: Why am I not getting the results I expect...
On Wed, 5 Jul 2000, Sudhakar Chandra wrote:
I did not find any nuber greater than 24 when executed this with a
printf;s etc
Please send the complete code.
The modifications made by me for printing were....
main()
{
>
> int num_of_arts;
> int display_article_number;
> int * article_displayed; /* Flags stored here */
>
>
> num_of_arts = 24;
>
> /* Make enough space to store the flags */
> article_displayed = (int *) calloc(num_of_arts, sizeof(int));
>
>
>
> display_article_number = 1 + (int) (((float) num_of_arts) * random() /
> (RAND_MAX+1.0));
>
printf("%d\n",display_article_number);
> while (*(article_displayed+display_article_number-1) == 1) {
//replaced this by
while (1) {// I think there is some code before this line in yr orig script
> display_article_number = 1 + (int) (((float) num_of_arts) * random() /
> (RAND_MAX+1.0));
another printf
> }
>
>
>
> I expect this piece of code to generate a random number between 1 and 24.
In my case it did.
-----------
#!!! If anything can go wrong, _FIX_ it. (To hell with MURPHY)
Ajay kumar Dwivedi
ajayd@xxxxxxxxxx