+ 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

17th Feb 2017, 4:32 PM
Himanshu Kumar
Himanshu Kumar - avatar
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.
17th Feb 2017, 4:35 PM
Mario L.
Mario L. - avatar
+ 1
thanks.. gotcha
17th Feb 2017, 4:39 PM
Himanshu Kumar
Himanshu Kumar - avatar