1) ELSEIF-
When there are multiple choices and the user has to select one, the ELSEIF statement can be used.
Example:-
In the above program, program will determine greatest number among three entered number.
Remember, while entering numbers , enter three different numbers.
Output:-
2) SELECT CASE:-
SELECT CASE , is used to automatically determine a program decision by checking the value of a variable.
Syntax: -
SELECT CASE variable
CASE comparison value : execution code
:
:
:
CASE ELSE
END SELECT
Example:- 1
We will make a program to print weekly day, by entering corresponding number.
In the above program, program will print day after entering corresponding day number.
Output:-
Example:- 2
Output:-
In the above program we will enter character & program will show you related months staring from the entered character.
Output:-
b) To calculate the area of a rectangle, square , circle and triangle. Use ON GOSUB, until the user wants.
PRACTICE PROGRAMS
1) SELECT CASE BASED
MAKE A PROGRAM TO PRINT NUMBER OF DAYS OF THE MONTH. GET INPUT OF MONTH NAME AND DISPLAY THEIR DAYS.
NOTE: IN THE FOLLOWING PROGRAM REMEMBER TO INPUT MONTH NAME IN CAPITALS AS WELL AS WITH CORRECT SPELLING
CLS
INPUT " ENTER MONTH TO SEE NUMBERS DAYS IT HAS ";M$
SELECT CASE M$
CASE "JANUARY" : PRINT 31
CASE "FEBRUARY" : PRINT 28
CASE "MARCH" : PRINT 31
CASE "APRIL" : PRINT 30
CASE "MAY" : PRINT 31
CASE "JUNE" : PRINT 30
CASE "JULY" : PRINT 31
CASE "AUGUST" : PRINT 31
CASE "SEPTEMBER" : PRINT 30
CASE "OCTOBER" : PRINT 31
CASE "NOVEMBER" : PRINT 30
CASE "DECEMBER" : PRINT 31
CASE ELSE: ? " INVALID MONTH"
END SELECT
END
2) SELECT CASE BASED
MAKE A PROGRAM JUST LIKE MOBILE IN WHICH ASK THE USER TO DIAL USSID AND DISPLAY MENU. CHOOSE APPROPRIATE MENU AND DISPLAY RESULT ACCORDINGLY.
CLS
INPUT " ENTER USSID-"; U$
IF U$="*121#" THEN
PRINT "1. BALANCE INQUIRY"
PRINT "2. TARRIF"
PRINT "3. INTERNET OFFERS"
PRINT
INPUT " ENTER CHOICE- " ; C
SELECT CASE C
CASE 1: PRINT " YOUR BALANCE IS RS. 12.50. VALID UP TO 23/10/2023."
CASE 2: PRINT " RECHARGE TODAY WITH RS.11 & GET LOCAL/STD CALLS 20 p/min FOR 28 DAYS."
CASE 3: PRINT "RECHARGE WITH RS. 99 & GET 1 MONTH UNLIMITED 4G DATA"
CASE ELSE : PRINT " INVALID INPUT"
END SELECT
ELSE
PRINT "INVALID USSID.CONNECTION LOST"
END IF
END
3) GOSUB STATEMENT
IN THIS PROGRAM,WE WILL ENTER FIVE NAMES. IF NAME EQUAL TO AMIT THEN A LABEL WILL BE CALLED AND WELCOME TO AMIT WILL BE DISPLAYED
CLS
FOR N= 1 TO 5
INPUT " ENTER NAME " ; N$
IF N$="AMIT" THEN GOSUB A
NEXT N
END
A:
PRINT " WELCOME AMIT"
RETURN
Click on Subscribe and enter your e-mail id to get more updates directly to you.
When there are multiple choices and the user has to select one, the ELSEIF statement can be used.
Example:-
In the above program, program will determine greatest number among three entered number.
Remember, while entering numbers , enter three different numbers.
Output:-
2) SELECT CASE:-
SELECT CASE , is used to automatically determine a program decision by checking the value of a variable.
Syntax: -
SELECT CASE variable
CASE comparison value : execution code
:
:
:
CASE ELSE
END SELECT
Example:- 1
We will make a program to print weekly day, by entering corresponding number.
In the above program, program will print day after entering corresponding day number.
Output:-
Example:- 2
Output:-
In the above program we will enter character & program will show you related months staring from the entered character.
LAB ACTIVITY
1. Write Programs for the following problems.
b) To calculate the area of a rectangle, square , circle and triangle. Use ON GOSUB, until the user wants.
PRACTICE PROGRAMS
1) SELECT CASE BASED
MAKE A PROGRAM TO PRINT NUMBER OF DAYS OF THE MONTH. GET INPUT OF MONTH NAME AND DISPLAY THEIR DAYS.
NOTE: IN THE FOLLOWING PROGRAM REMEMBER TO INPUT MONTH NAME IN CAPITALS AS WELL AS WITH CORRECT SPELLING
CLS
INPUT " ENTER MONTH TO SEE NUMBERS DAYS IT HAS ";M$
SELECT CASE M$
CASE "JANUARY" : PRINT 31
CASE "FEBRUARY" : PRINT 28
CASE "MARCH" : PRINT 31
CASE "APRIL" : PRINT 30
CASE "MAY" : PRINT 31
CASE "JUNE" : PRINT 30
CASE "JULY" : PRINT 31
CASE "AUGUST" : PRINT 31
CASE "SEPTEMBER" : PRINT 30
CASE "OCTOBER" : PRINT 31
CASE "NOVEMBER" : PRINT 30
CASE "DECEMBER" : PRINT 31
CASE ELSE: ? " INVALID MONTH"
END SELECT
END
2) SELECT CASE BASED
MAKE A PROGRAM JUST LIKE MOBILE IN WHICH ASK THE USER TO DIAL USSID AND DISPLAY MENU. CHOOSE APPROPRIATE MENU AND DISPLAY RESULT ACCORDINGLY.
CLS
INPUT " ENTER USSID-"; U$
IF U$="*121#" THEN
PRINT "1. BALANCE INQUIRY"
PRINT "2. TARRIF"
PRINT "3. INTERNET OFFERS"
INPUT " ENTER CHOICE- " ; C
SELECT CASE C
CASE 1: PRINT " YOUR BALANCE IS RS. 12.50. VALID UP TO 23/10/2023."
CASE 2: PRINT " RECHARGE TODAY WITH RS.11 & GET LOCAL/STD CALLS 20 p/min FOR 28 DAYS."
CASE 3: PRINT "RECHARGE WITH RS. 99 & GET 1 MONTH UNLIMITED 4G DATA"
CASE ELSE : PRINT " INVALID INPUT"
END SELECT
ELSE
PRINT "INVALID USSID.CONNECTION LOST"
END IF
END
3) GOSUB STATEMENT
IN THIS PROGRAM,WE WILL ENTER FIVE NAMES. IF NAME EQUAL TO AMIT THEN A LABEL WILL BE CALLED AND WELCOME TO AMIT WILL BE DISPLAYED
CLS
FOR N= 1 TO 5
INPUT " ENTER NAME " ; N$
IF N$="AMIT" THEN GOSUB A
NEXT N
END
A:
PRINT " WELCOME AMIT"
RETURN
Click on Subscribe and enter your e-mail id to get more updates directly to you.
No comments:
Post a Comment
Thank you so much to like us.