Skip to main content

QBASIC MULTIPLE CHOICE & SUB PROCEDURES CLASS VII

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.
 


LAB ACTIVITY
1. Write Programs for the following problems.
 a) To make a four function calculator , Use SELECT CASE.



b) To calculate the area of a rectangle, square , circle and triangle. Use ON GOSUB.

 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.




Comments

Popular posts from this blog

QBASIC STATEMENTS CLASS-VI

CONTROL STATEMENT-    The Control Statements are used for controlling the Execution of the program. We use control statements by two way 1) Unconditionally & 2) Conditionally GOTO STATEMENT- Unconditionally, we use GOTO statement. The Goto Statement is used for transferring the control to the other location for example- if you wants to transfer the control to the other place of the program then we can use the goto statement. When we use goto Statement then we have to supply a name along with a Goto Statement on which Control is transferred. The Name is user choice and Name must be defined with the help of a Colon. When Compiler transfers the Control of program to the Goto statement then statements of Goto block will be Executed and The Name of Goto Statements block is also called as the Label Name. GOTO statement uses line number or label Here, We will understand by an example CLS 1 PRINT " MY NAME IS  AMIT " :GOTO ABC 2 PRINT " I LI...

My Profile....

Mr. Shravan Kumar (IT Engineer) " Success is not final; failure is not fatal: It is the courage to continue that counts." It's pleasure to say that IT field is improving day by day and minute by minute. Today, Everything controlled and managed by computer. Businesses and companies use a computer to do marketing and business planning, they use a computer to record customer data, they use a computer to manage goods and services etc. Computer with an internet connection is really important for businesses and individuals. You can understand and analyze the importance of computer by seeing a revolution in offline and online business, online education, online business, online communication and internet banking. To store, access, manipulate, calculate, analyze data and information we use hardware devices and software application. Schools and colleges around the world are using computer and internet technologies to teach students digitally and creatively with...