Display powers in C++ loop -


i have solve following exercise

write program display 1,5,25,125 upto n terms.

i in 11th grade , have tried of many ways of writing program.
value of control variable one, , it's less n.
how should differ obeys above question?
please answer if in simple language.
should use special variable power?

thanks in advance, abhijith

print out old value times five, starting 1

basic mockup:

auto printexercise(std::size_t terms) -> void {     std::size_t lastresult = 1;     (std::size_t = 0; < terms; ++i) {         std::cout << std::to_string(lastresult) << std::endl;         lastresult *= 5;     } } 

edit: turns out overthought this. easier print power of control variable.

auto printexercise(std::size_t terms) -> void {     (std::size_t = 0; < terms; ++i) {         std::cout << std::to_string(pow(5,n)) << std::endl;     } } 


Comments