म
MarathiCodeby Sprout Tech
Documentation topicsConditional Statements
MarathiCode v0.2.0

Conditional Statements

जर <अट> तर { … } नाहीतर { … }

जर runs a block when its condition is true. The condition is followed by तर, and every branch is a block in braces.

if.mr
चल गुण = 85
जर गुण >= 35 तर {
    छापा("उत्तीर्ण")
}
Output (आउटपुट)
उत्तीर्ण

नाहीतर (else)

if_else.mr
चल गुण = 25
जर गुण >= 35 तर {
    छापा("उत्तीर्ण")
} नाहीतर {
    छापा("अनुत्तीर्ण")
}
Output (आउटपुट)
अनुत्तीर्ण

नाहीतर जर (else-if)

Conditions are checked in order, and only the first true branch runs:

else_if.mr
चल गुण = 72
जर गुण >= 90 तर {
    छापा("उत्कृष्ट")
} नाहीतर जर गुण >= 60 तर {
    छापा("प्रथम श्रेणी")
} नाहीतर जर गुण >= 35 तर {
    छापा("उत्तीर्ण")
} नाहीतर {
    छापा("अनुत्तीर्ण")
}
Output (आउटपुट)
प्रथम श्रेणी

Rules

  • The condition can be any value; see truthiness.
  • तर and the braces are required, even for a single statement.
  • नाहीतर must be followed by a block or by another जर.
  • Each branch is a new scope.