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
1

Expert's answer

2014-05-09T09:18:56-0400

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>

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!
LATEST TUTORIALS
APPROVED BY CLIENTS