maybe u can give me some advice, i have this C code
 

#include<stdio.h>

#include<stdlib.h>

 

main(void)

{

        int plus_cnt = 0;

        int minus_cnt = 0;

            int median = RAND_MAX/2;

            int i, r = 0;

 

for(i=0; i < 500; i++)

{

r = rand( );

if (r > median)

++minus_cnt;

else

++plus_cnt;

printf( "%4d", plus_cnt - minus_cnt);

        }

}
 the above will run, but when i change it to while, nothing happens
 

#include<stdio.h>

#include<stdlib.h>

 

main(void)

{

        int plus_cnt = 0;

        int minus_cnt = 0;

            int median = RAND_MAX/2;

            int i, n, r = 0;

 

            while (i++ < n)

            {

                        r = rand( );

if (i == (n-1))

++minus_cnt;

else

++plus_cnt;                     

                        printf( "%4d", rand( ));

            }

 



                
---------------------------------
Do you Yahoo!?
 Yahoo! Mail - You care about security. So do we.

[Non-text portions of this message have been removed]






>-----------------------------------------~-~>
CHECK THE ARCHIVE BEFORE POSTING!!!! Archive is available at 
http://www.eScribe.com/software/C-Paradise/

>------------------------------------------_->


 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/C-Paradise/

<*> To unsubscribe from this group, send an email to:
    [EMAIL PROTECTED]

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/
 



Reply via email to