Lesson 8 of 23
while மற்றும் do-whilewhile and do-while
9 min 25 XP
எத்தனை முறை என்று தெரியாதபோது while. n % 10 கடைசி இலக்கம், n / 10 கடைசி இலக்கத்தை நீக்கும். இந்த இரண்டு tricks மூலம் reverse, palindrome number, Armstrong number போன்ற கேள்விகளைத் தீர்க்கலாம்.
Use while when you don't know how many times to loop. n % 10 is the last digit and n / 10 removes it. These two tricks solve reverse, palindrome-number and Armstrong-number questions.
Example: edit me and press Run
Press Run to see the result here.Condition ஒருபோதும் false ஆகாவிட்டால் loop முடிவில்லாமல் ஓடும். இங்கே சில வினாடிகளில் தானாக நிறுத்தப்படும்.
If the condition never becomes false the loop runs forever. Here it is stopped automatically after a few seconds.