• Home
  • Courses
  • School
  • Programs
  • Problems
  • Contact Us
  • My account
  • Register

Have any question?

(+91) 98222 16647
info@simplycoding.in
RegisterLogin
Simply Coding
  • Home
  • Courses
  • School
  • Programs
  • Problems
  • Contact Us
  • My account
  • Register

QBasic

Quick Revision of QBASIC Commands and Programs

  • Categories QBasic

Below are QBasic Commands and questions.

Q 1.What is QBasic?

Ans:

QBasic is a version of BASIC programming language developed by Microsoft Corporation.

Q 2.What is full form of BASIC?

Ans:

Full form of Basic is Beginners All Purpose Symbolic Instruction Code.

Q 3.Why is QBasic so popular?

Ans:

QBasic is popular as

    1. It is available as freeware and many tutorials, forums are available to learn the language.
    2. It is easy to understand and write programs using a IDE (Integrated Development Environment)
Q 4.What is LET statement?

Ans:

LET statement is used to initialize variables with values at the start of the program. Data is stored in variables by using LET statement.

e.g. LET A = 12

Q 5.What is READ DATA statement?

Ans:

READ … DATA statement allows us to read many data items in a single statement. The syntax for it is as below

Syntax

Read var1, var2

Read var3…

:

DATA val1, val2, val3

Key Points:

      1. DATA statement can appear anywhere in the program but before END
      2. Read statement reads the data in the order in which they are written in DATA statement.
      3. If DATA values are less than that required by READ, then “Out of DATA” message is displayed.
      4. If there is a mismatch in data type of variable, it will give an error.
Q 6.What are functions? What are the advantages of using functions?

Ans:

Functions are ready made programs that can be used anywhere in the programs. The advantages of functions are

      1. It helps to make our work simpler and faster
      2. It reduces the length of the program
Q 7.What are different types of Standard Library Functions in QBasic?

Ans:

There are three types of functions in QBASIC.

      1. Mathematical Functions
      2. String Functions
      3. Conversion Functions
Q 8.What are various Mathematical Functions?

Ans:

Different Mathematical Functions are.

      1. ABS(): Returns absolute value of numeric expression
        1. SYNTAX: ABS(n)
        2. EXAMPLE: ABS (-5) gives output as 5
      2. SGN(): Returns -1,1 or 0 to indicate sign of numeric expression.
        1. SYNTAX: SGN(n)
        2. EXAMPLE: SGN (-5) gives output as -1
      3. INT(): Returns the next integer which is less than or equal to given value.
        1. SYNTAX: INT(n)
        2. EXAMPLE: INT (-5.3) gives output as -6
      4. FIX(): Truncates the fractional part to give Integer value.
        1. SYNTAX: FIX(n)
        2. EXAMPLE: FIX (5.3) gives output as 5
      5. CINT(): Rounds off the value to nearest integer.
        1. SYNTAX: CINT(n)
        2. EXAMPLE: INT (5.6) gives output as 6
      6. SQR(): Gives the square root of the number.
        1. SYNTAX: SQR(n)
        2. EXAMPLE: SQR (4) gives output as 2
Q 9.What are various String Functions?

Ans:

String functions are used for working with Strings. Different String Functions are –

      1. + Operator: Addition (+) operator can be used to concatenate two strings
        1. SYNTAX: String1 + String2
        2. EXAMPLE: “Name ” + “Surname”
      2. LEN(): Returns the length of string in characters
        1. SYNTAX: LEN(String)
        2. EXAMPLE: LEN( “name”) gives output as 4
      3. RIGHT$(): Returns n characters from the right of the string
        1. SYNTAX: RIGHT$(String,n)
        2. EXAMPLE: RIGHT$( “name”, 2) gives output as “me”
      4. LEFT$(): Returns n characters from the left of the string
        1. SYNTAX: LEFT$(String,n)
        2. EXAMPLE: LEFT$( “name”, 2) gives output as “na”
      5. MID$(): Returns substring, starting from m returns n characters from the beginning of the string
        1. SYNTAX: MID$(String,m,n)
        2. EXAMPLE: MID$( “name”, 2,1) gives output as “m”
      6. LCASE$(), UCASE$(): Converts to lower case and upper case respectively.
        1. SYNTAX: UCASE$(String), LCASE$(String)
        2. EXAMPLE: UCASE$( “name”) gives output as “NAME”
      7. STRING$(): Returns a string formed by repeating a character for a specified number of times
        1. SYNTAX: STRING$(n,Character)
        2. EXAMPLE: STRING$( 2,”x”) gives output as xx
      8. SPACE$(): Returns n number of spaces
        1. SYNTAX: SPACE$(n)
        2. EXAMPLE: SPACE$( 5 ) gives output as “ ”
Q 10.  What are various Conversion Functions?

Ans:

Conversion functions are used to perform conversion operations on variables.

      1. ASC(): Returns the ASCII code of given character
        1. SYNTAX: ASC(Character)
        2. EXAMPLE: ASC(“A”) will return 65
      2. CHR$(): Returns the character of given ASCII code
        1. SYNTAX: CHR$(n)
        2. EXAMPLE: CHR$(65) will return A
      3. STR$(): Converts numeric value to String
        1. SYNTAX: STR$(n)
        2. EXAMPLE: ASC(234) will return string “234”
      4. VAL(): Converts String into its numeric value
        1. SYNTAX: VAL(String)
        2. EXAMPLE: VAL(“23”) will return 23
Q 11.What is ASCII?

Ans:

ASCII Stands for American Standard Code for Information Interchange. There are 256 ASCII codes from 0 to 255. Codes for common alphabets are as following

    • A to Z = 65 to 90
    • a to z = 97 to 122
    • 0 to 9 = 48 to 57

QBasic Questions

Q 1.  Fill in the blanks
  1. ______________ function returns length of the string

Ans. LEN()

 

  1. ______________ function return n number of spaces

Ans. SPACE$()

 

  1. ______________ function returns n character from right of the string

Ans. RIGHT$()

 

  1. ______________ function converts string to number

Ans. VAL()

 

  1. ______________ function returns ASCII code of character

Ans. ASC()

 

  1. ______________ function returns a value indicating the sign of number

Ans. SGN()

 

  1. ______________ function converts all characters to uppercase

Ans. UCASE$()

 

  1. ______________ function truncates the fractional part of the number

Ans. FIX()

 

  1. ______________ function returns a substring from any position

Ans. MID$()

 

  1. ______________ function rounds off a number to the nearest integer

Ans. CINT()

 

  1. ______________ function returns n number of characters from right of the string

Ans. RIGHT$()

 

  1. ______________ function returns nearest integer which is less than or equal to value

Ans. INT()

 

  1. ______________ function returns character of given ASCII code

Ans. CHR$()

 

  1. ______________ function converts numeric value to string

Ans. STR$()

 

  1. ______________ operator can concatenate string.

Ans. +

 

  1. ______________ statement is used to initialize a variable at the start of the program

Ans. LET

 

  1. ______________statement is used to read many data items in single statement

Ans. READ … DATA

 

  1. The values stored in DATA statement are separated by ______________.

Ans. comma

 

  1. DATA statement must appear before the ______________

Ans. END

 

  1. ______________ message is displayed if DATA statement contains less values than what is required by READ statement.

Ans. “Out of DATA”

 

  1. _______, _______, _________are three types of standard library functions.

Ans. Mathematical,String, Conversion.

 

Q 2.What is full form of following
    1. ASCII
    2. IDE
    3. BASIC

Ans:

    1. American Standard Code for Information Interchange
    2. Integrated Development Environment
    3. Beginners All Purpose Symbolic Instruction Code
Q 3.What is the output of following statements
    1. ABS(-22.8)
    2. SGN(-22.8)
    3. INT(22.8)
    4. INT(-22.8)
    5. FIX(22.8)
    6. CINT(22.5)
    7. CINT(22.6)
    8. CINT(-22.5)
    9. CINT(-22.6)

Ans

    1. 8
    2. -1
    3. 22
    4. -23
    5. 22
    6. 22
    7. 23
Q 4.Identify if it is the right syntax for the command
    1. LEN$(“ABC”)
    2. SGN(“1.23”)
    3. RIGHT(“ABC”,2)
    4. ASC(“ABC”)
    5. VAL$(4)
    6. LEFT$(2,”ABC”)
    7. STRING(2,”ABC”)
    8. MID$(2,4,”ABC”)

Ans

    1. LEN(“ABC”)
    2. SGN(1.23)
    3. RIGHT$(“ABC”,2)
    4. ASC(“ABC”) – Will only return ASCII value of A
    5. VAL(“4”)
    6. LEFT$(”ABC”,2)
    7. STRING(2,”ABC”) – Will replicate A 2 times
    8. MID$(”ABC”, 2,4)
Q 5.What is the output of following statements
    1. LEN(“I AM”)
    2. RIGHT$(“SIMPLY”,10)
    3. LEFT$(“SIMPLY”,3)
    4. MID$(“SIMPLY”,2,3)
    5. UCASE$(“Simply”)
    6. STRING$(4,“Simply”)
    7. PRINT “SIMPLY”;SPACE$(4);”CODING”
    8. PRINT “SIMPLY”, “CODING”

Ans

    1. 8
    2. SIMPLY
    3. SIM
    4. IMP
    5. SIMPLY
    6. SSSS
    7. SIMPLY CODING
    8. SIMPLY CODING
Q 6.What is the output of following statements
    1. ASC(“B”)
    2. STR$(65)
    3. VAL(“22.4”)
    4. CHR$(98)

Ans

    1. 66
    2. 65
    3. 22.4
    4. b

Programs

Q 1.  Write a program to enter your name and print it?

Ans.

CLS
Input 'Enter you name';n$
Input " Enter the age";A
Print " The age is ";A
Print 'The name is';n$
End
Q 2.  Write a program to find the area of rectangle.

Ans.

Cls
Input " enter the length " ;l
Input " enter the breadth " ;b
let A = l*b
Print" the area of rectangle=" ;a
End
Q 3.Write a program to find the area of the triangle.

Ans.

Cls
Input " enter the base" ;b
Input " enter the height" ;h
let T = 1/2*b*h
Print" The area of triangle=" ;T
End
Q 4.Write a program to find the area of the circle.

Ans.

Cls
Input" Enter the radius " ;R
Let C=22/7*R^2
Print " The area of circle =" ;C
End
Q 5.Write a program to find the circumference of the circle.

Ans.

Cls
Input" Enter the radius " ;R
Let Circumference=22/7*R*2
Print " The area of circle =" ;Circumference
End
Q 6.Write a program to find out the simple Interest.

Ans.

Cls
Input " Enter the Principal";P
Input " Enter the Rate";R
Input " Enter the Time";T
Let I = P*T*R/100
Print " The simple Interest = ";I
End
Q 7.Write a program to find the average of three different numbers.

Ans.

Cls
Input" Enter the number " ;A
Input" Enter the number " ;B
Input" Enter the number " ;C
Let Avg= (A+B+C)/3
Print" The average=" ;Avg
End
Q 8.Write a program to enter any number and find out whether it is negative or positive.

Ans.

CLS
Input “Enter the number”; N
If N>0 Then
Print “ The number is positive”
Else
Print “The number is negative”
EndIf
End
Q 9.Write a program to enter any number and find out whether it is even or odd using select case statement.

Ans.

Cls
Input “Enter any number” ;N
R=N mod 2
Select case R
Case = 0
Print “The number is Even number”
Case Else
Print “The number is odd number”
End Select
End
Q 10. Write a program to check the numbers between 1 & 3.

Ans.

Cls
Input “Enter the numbers between 1-3”;N
Select case N
Case 1
Print “It’s number 1”;
Case 2
Print “It’s a number 2”;
Case 3
Print “It’s a number 3”
Case else
Print “It’s out of range”;
End select
End
Q 11. Write a program to enter any alphabet and test alphabet is ‘a’ or not using the select case statement.

Ans.

Cls
Input “Enter the alphabet”;A$
A$=UCase$ (A$)
Select Case A$
Case ‘A’
Print “It’s alphabet A”
Case Else
Print “It’s not alphabet A”
End Select
End
Q 12. Write a program to enter any alphabet and find out whether the number is vowel or alphabet.

Ans.

Cls
Input “Enter Letters/Alphabet”;A$
A$ = UCase $ (A$)
Select case A$
Case “A”, “E”, “I”, “O”, “U”
Print “Its’ a vowel”
Case Else
Print “ It’s not a vowel”
End Select
End
Q 13. Generate the following numbers using For….Next…..Loop.    1,2,3,4,…,50

Ans.

CLS
For I = 1 to 50 Step 1
Print I
Next I
End
Q 14. Generate the following numbers using For….Next…..Loop.   –    2,4,6,8,10,…50

Ans.

Cls
For I = 2 to 50 Step 
Print I
Next I
End
  • Share:
author avatar
Simply Coding

Previous post

Computer Networking Notes and Questions to revise in 1 Hour
June 13, 2020

Next post

MS Access Notes and Questions
June 15, 2020

Leave A Reply Cancel reply

You must be logged in to post a comment.

Categories

Recent Posts

  • ISC Class 12 Computer Science previous year paper (2020)
  • ISC Class 12 Computer Science previous year paper (2017)
  • CBSE Class 12 Computer Science Marking Scheme (2020-21)
  • ICSE Class 10 COMPUTER APPLICATIONS previous year paper (2017)
  • ICSE Class 10 COMPUTER APPLICATIONS previous year paper (2016)
Simply Coding Computer Courses for School                Privacy Policy     Terms of Use     Contact Us

© 2021 Simply Coding

Login with your site account

Lost your password?

Not a member yet? Register now

Register a new account

Are you a member? Login now