QBASIC ELSE/ELSEIF EXAMPLES..! SCHOOL LEVEL 8, 9, 10.

 


Welcome to the post. In this post we are going to learn about (ELSEIF/ELSE ) conditions.
I would like to type in Nepali for more effective understanding. 

हमि सर्वपर्थम else/elseif ले के काम गर्छ र कहाँ पर्योग हुन्क्ष भन्ने कुरा बुझौ। यो एंड प्रोग्राम को conclusion हेर्ने र तेइ अनुसार प्रोग्राम लाई  अगाडी बढाउने  काम गर्छ ।मानौ  तपाई बजार जानुभयो तपैसंगा १०० रुपैया छ र तपाईले  ५० rs  को समान किन्नुवायो येदि तपाइको पैसाले पुग्क्ष भने किन्नुहुन्क्ष नत्र किन्नु हुदैन येस्मा  else/elseif  ई २ condition लागेको छ । एसको QBASIC example  हेरौ र बुझौ ।

CLS

amount = 100
goods_price = 50
IF amount >= goods_price THEN
   PRINT "You can buy!"
ELSE
   PRINT "You can't buy!"
END IF

END

यसै गरि अनन्य Example हरु पनि हेरौ ।
Example #1

CLS
grade = 75
IF grade >= 90 THEN
   PRINT "Excellent!"
ELSEIF grade >= 80 THEN
   PRINT "Very Good!"
ELSEIF grade >= 70 THEN
   PRINT "Good!"
ELSE
   PRINT "Needs Improvement!"
END IF
END

Example #2

CLS
num = 7
IF num = 0 THEN
   PRINT "Zero"
ELSEIF num > 0 THEN
   PRINT "Positive"
ELSE
   PRINT "Negative"
END IF
END

Example #3


CLS
age = 18
IF age < 13 THEN
   PRINT "Child"
ELSEIF age >= 13 AND age < 18 THEN
   PRINT "Teenager"
ELSEIF age >= 18 AND age < 65 THEN
   PRINT "Adult"
ELSE
   PRINT "Senior"
END IF
END

Example #4


CLS
hour = 15
IF hour < 12 THEN
   PRINT "Good Morning!"
ELSEIF hour >= 12 AND hour < 18 THEN
   PRINT "Good Afternoon!"
ELSE
   PRINT "Good Evening!"
END IF
END

Example #5


CLS
month = 6
IF month = 12 OR month = 1 OR month = 2 THEN
   PRINT "Winter"
ELSEIF month >= 3 AND month <= 5 THEN
   PRINT "Spring"
ELSEIF month >= 6 AND month <= 8 THEN
   PRINT "Summer"
ELSE
   PRINT "Autumn"
END IF
END

Example #6


CLS
num = 42
IF num < 0 THEN
   PRINT "Negative"
ELSEIF num > 0 THEN
   PRINT "Positive"
ELSE
   PRINT "Zero"
END IF
END

Example #7


CLS
num = 25
IF num MOD 2 = 0 THEN
   PRINT "Even"
ELSE
   PRINT "Odd"
END IF
END

Example #8


CLS
num = 120
IF num < 0 THEN
   PRINT "Negative"
ELSEIF num > 0 THEN
   PRINT "Positive"
ELSE
   PRINT "Zero"
END IF
END

Example #9


CLS
score = 85
IF score >= 90 THEN
   PRINT "A"
ELSEIF score >= 80 THEN
   PRINT "B"
ELSEIF score >= 70 THEN
   PRINT "C"
ELSEIF score >= 60 THEN
   PRINT "D"
ELSE
   PRINT "F"
END IF
END

Example #10


CLS
num = 7
IF num = 0 THEN
   PRINT "Zero"
ELSEIF num > 0 THEN
   IF num MOD 2 = 0 THEN
      PRINT "Positive Even"
   ELSE
      PRINT "Positive Odd"
   END IF
ELSE
   IF num MOD 2 = 0 THEN
      PRINT "Negative Even"
   ELSE
      PRINT "Negative Odd"
   END IF
END IF
END




If you Found this post is useful please share with your friends. Thankyou.



















Post a Comment

Previous Post Next Post