Lesson 11 of 34
while மற்றும் do-while loopswhile and do-while Loops
8 min 25 XP
எத்தனை முறை loop இயங்க வேண்டும் என்று முன்பே தெரியாதபோது while பயன்படுத்துங்கள். Condition false ஆகும் வரை இயங்கும். Condition-ஐ மாற்ற மறந்தால் loop முடிவில்லாமல் ஓடும்!
Use while when you don't know in advance how many times to loop. It runs until the condition becomes false. Forget to change the condition and the loop never ends!
Example: edit me and press Run
Press Run to see the result here.do-while, condition-ஐ கடைசியில் சோதிக்கும். ஆகவே அது குறைந்தது ஒருமுறையாவது இயங்கும்.
do-while checks its condition at the end, so the body always runs at least once.
Example: edit me and press Run
Press Run to see the result here.n % 10 கடைசி இலக்கத்தைத் தரும், n / 10 கடைசி இலக்கத்தை நீக்கும். இலக்க problems-ல் இந்த இரண்டும் மிக முக்கியம்.
n % 10 gives the last digit and n / 10 removes it. These two tricks solve most digit problems in interviews.