+ 1

why output is repetitive 1

#include<iostream> #include<conio.h> using namespace std; int main() { long int a, i ,s=0; for(i=11;i<=99;i++) { cout<<i<<":"; a=i%10; s=s*10+a; i=i/10; } getch(); return 0; }

29th Aug 2020, 5:31 PM
Nariman Tajari
Nariman Tajari - avatar
3 odpowiedzi
+ 2
in loop first i =11, you printing it. But after I = i /10 => now i=1, then i++ cause I =2. It prints again.. Next by i=i/10 make i =0... Next i++ cause i =1 it prints.. Next I =i /10 => I =0, I ++ this will repeating infinitly.. Because i<=99 always true... So output is what you seen...
29th Aug 2020, 6:23 PM
Jayakrishna 🇮🇳
0
Jayakrishna🇮🇳 i appreciate your response but i didnt understand how i++ would be executed for i=1 as you said when it is not in the domain of loop(i=11;i=99;)
9th Nov 2020, 10:24 AM
Nariman Tajari
Nariman Tajari - avatar
0
Jayakrishna🇮🇳 aha i got it after contemplating 😀😸
11th Nov 2020, 6:31 PM
Nariman Tajari
Nariman Tajari - avatar