+ 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; }
3 Réponses
+ 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...
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;)
0
Jayakrishna🇮🇳 aha i got it after contemplating 😀😸