Lesson 12 of 34

break மற்றும் continuebreak and continue

7 min 25 XP

break loop-ஐ உடனே நிறுத்தும். continue அந்தச் சுற்றின் மீதியைத் தவிர்த்து அடுத்த சுற்றுக்குச் செல்லும்.

break stops the loop immediately. continue skips the rest of this round and moves on to the next one.

Example: edit me and press Run

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

ஒரு எண் prime-ஆ என்று சோதிக்க: 2 முதல் வகுத்துப் பாருங்கள்; ஒரு வகுத்தி கிடைத்தவுடன் break.

To test whether a number is prime, try dividing from 2 upwards and break as soon as you find a divisor.

Example: edit me and press Run

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

Challenge

+25 XP

ஒரு எண் n-ஐப் படித்து அது prime ஆக இருந்தால் "Prime", இல்லையெனில் "Not prime" என்று print செய்யுங்கள். (1 prime அல்ல.)

Read a number n. Print "Prime" if it is prime, otherwise "Not prime". (1 is not prime.)

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