Question #42226

write the c code to find and display the largest power of 5 that is less than 10000 using a while statement your code cannot use the math class

Expert's answer

Answer on Question #42226 - Programming - C++

write the c code to find and display the largest power of 5 that is less than 10000 using a while statement your code cannot use the math class

ANSWER


#include <stdio.h>
void main()
{
    int power = 0;
    int result = 1;
    while (result < 10000)
    {
        result *= 5;
        power++;
    }
    power--;
    printf("The largest power of 5 that is less than 10000:\t%d\n", power);
}


http://www.AssignmentExpert.com/</stdio.h>

LATEST TUTORIALS
APPROVED BY CLIENTS