0

What is the logic behind this code to find this output?

int a=14; for( int i = 0; i<=7; i ++) { a++; } cout<<a;

3rd Sep 2020, 8:02 PM
Suparna Podder
Suparna Podder - avatar
2 Answers
+ 1
When loop runs first time "a" becomes 15 and "i" becomes 1 so when "a" becomes 21 ,"i" becomes 7 ,since "i" is still less than equal to 7 so loops runs one last time and a final value comes out as 22
3rd Sep 2020, 8:12 PM
Abhay
Abhay - avatar
0
8 times incrementing 'a' value. Just a quiz question..?
3rd Sep 2020, 8:21 PM
Jayakrishna 🇼🇳