Lesson 5 of 23

if, else और else if

8 min 25 XP

if कोड तभी चलाता है जब उसकी condition true हो। ज़्यादा विकल्पों के लिए else if और बाकी सब के लिए else लें। C में 0 का अर्थ false है और कोई भी non-zero value true है।

Example: edit me and press Run

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

if (x = 5) x में 5 रख देता है और हमेशा true रहता है! तुलना के लिए == लें। यह bug C का क्लासिक जाल है।

Challenge

+25 XP

एक संख्या पढ़ें। "Positive", "Negative" या "Zero" print करें।

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