+ 1
Please explain the working of the following code:
#include <iostream> using namespace std; int main(){ int c = 1; while (c<10){ c *= 5; } cout<<c; return 0; } Output : 25
2 ответов
+ 2
c is 1, check if c is less than 10, it is, c becomes multiplied by 5 so c is 5 now.
check if c is less than 10, true, multiply by 5 equals 25.
check, false, leave the loop.
print 25 to console.
+ 1
thanks.. gotcha