Thread: FOR and WHILE

  1. #1
    Registered User
    Join Date
    Oct 2001
    Posts
    44

    FOR and WHILE

    could anyone convert this FOR LOOP into a WHILE LOOP for me:

    for (counter_2 = 0; counter_2 < min_exponent; counter_2 ++)
    answer *= base;

    this is what i got but i dont think it is right:

    while (counter_2 < min_exponent)
    {
    counter_2 ++;
    answer *= base;
    }

    thanks in advance,
    dave.
    Dangerous Dave

  2. #2
    &TH of undefined behavior Fordy's Avatar
    Join Date
    Aug 2001
    Posts
    5,793
    Have you initialised "counter_2 = 0;" before going into the loop?

Popular pages Recent additions subscribe to a feed