Lesson 6 of 34

if மற்றும் else: முடிவெடுத்தல்if and else: Making Decisions

8 min 25 XP

ஒரு condition true ஆக இருந்தால் மட்டும் code-ஐ இயக்க if பயன்படுத்துகிறோம். இல்லையெனில் else பகுதி இயங்கும். Condition-ஐ ( ) brackets உள்ளே எழுத வேண்டும்.

if runs code only when a condition is true; otherwise the else part runs. The condition goes inside ( ) brackets.

Example: edit me and press Run

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

ஒப்பீட்டு operators: == சமம், != சமமில்லை, > பெரியது, < சிறியது, >= பெரியது அல்லது சமம், <= சிறியது அல்லது சமம். இவை boolean (true/false) மதிப்பைத் தரும்.

Comparison operators: == equal, != not equal, > greater, < less, >= greater or equal, <= less or equal. Each gives a boolean (true/false).

Example: edit me and press Run

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

= மதிப்பைச் சேமிக்கும், == ஒப்பிடும். இதைக் குழப்புவது மிகச் சாதாரண தவறு.

= stores a value, == compares. Mixing them up is one of the most common mistakes.

Challenge

+25 XP

ஒரு மாணவரின் மதிப்பெண்ணைப் படித்து, 35 அல்லது அதற்கு மேல் இருந்தால் "Pass", இல்லையெனில் "Fail" என்று print செய்யுங்கள்.

Read a student's mark. Print "Pass" if it is 35 or more, otherwise print "Fail".

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