Lesson 8 of 23

while और do-while

9 min 25 XP

जब पता न हो कि loop कितनी बार चलेगा, तब while लें। n % 10 आखिरी अंक है और n / 10 उसे हटाता है। ये दो tricks reverse, palindrome-number और Armstrong-number सवाल हल करती हैं।

Example: edit me and press Run

Output Loading C (first time takes a few seconds)
Press Run to see the result here.

अगर condition कभी false न हो तो loop हमेशा चलता रहता है। यहाँ यह कुछ सेकंड बाद अपने-आप रोक दिया जाता है।

Challenge

+25 XP

एक संख्या पढ़ें। उलटने पर भी वही हो तो "Palindrome", वरना "Not palindrome" print करें। Input: 1221 → Output: Palindrome

Output Loading C (first time takes a few seconds)
Press Run to see the result here.