Chapter at a glance
Complete textbook solutions and programming guide for Class 10 Computer Science Unit 9 Programming in QBASIC, covering variable suffixes, control flow (IF, SELECT CASE, loops), built-in string functions, and full solved programs for prime numbers, palindromes, and Fibonacci series.
- QBASIC Variable Suffixes: $, %, &, !, #
- Conditional Branching: IF...THEN...ELSE, SELECT CASE
- Looping Constructs: FOR...NEXT, WHILE...WEND, DO...LOOP
- String Functions: LEN, LEFT$, RIGHT$, MID$, UCASE$
- Classic Algorithms: Palindromes, Primes, Factorials
Exam focus: Writing complete bug-free QBASIC programs for palindrome numbers, prime checking, multiplication tables, and string manipulations using MID$ and LEN.
Key formulas and definitions
- Integer Modulo: n MOD 10 extracts last digit; n \ 10 removes last digit
On this page (12 sections)
- The lesson in short
- Section A: QBASIC Fundamentals, Variables, and Control Flow
- VariablesVariable Naming Rules and Type Declaration Suffixes
- Control FlowBranching and Iterative Control Statements
- Section B: Standard Solved QBASIC Programs
- Program 1Program 1: Generate the Multiplication Table of a Number
- Program 2Program 2: Reverse a Number and Check for Palindrome
- Program 3Program 3: Check Prime Number
- Program 4Program 4: Generate the Fibonacci Series up to 10 Terms
- Section C: String Handling in QBASIC
- String FunctionsBuilt-in String Functions
- String ProgramProgram: Reverse a Given Word and Check Palindrome String
Solutions and answers
The lesson in short
QBASIC (Quick Beginners All-purpose Symbolic Instruction Code) is a classic structured, procedural programming language developed by Microsoft for teaching algorithmic problem-solving.
Featuring an integrated development environment with a syntax-checking editor and interpreter, QBASIC provides an accessible entry point to computational logic and imperative programming.
This chapter covers QBASIC language elements (character set, constants, variables, operators), standard control structures (IF...THEN, SELECT CASE, FOR...NEXT, WHILE...WEND, DO...LOOP), array handling, and complete solved programs aligned with the CDC Grade 10 curriculum.
Section A: QBASIC Fundamentals, Variables, and Control Flow
VariablesVariable Naming Rules and Type Declaration Suffixes
| Variable Type | Declaration Suffix | Storage Size | Example Valid Identifiers |
|---|---|---|---|
| String Variable | $ (Dollar sign) | Up to 32,767 characters | Name$, Address$, City$ |
| Integer Variable | % (Percent sign) | 2 bytes (-32,768 to 32,767) | Roll%, Age%, Count% |
| Long Integer | & (Ampersand) | 4 bytes (-2.14 billion to +2.14 billion) | Population&, Distance& |
| Single Precision | ! (Exclamation, default) | 4 bytes (7 digits of precision) | Marks!, Avg!, Rate! |
| Double Precision | # (Hash sign) | 8 bytes (15-16 digits of precision) | GrossSalary#, TotalAmount# |
Control FlowBranching and Iterative Control Statements
| Statement | Syntax Pattern | Operating Purpose |
|---|---|---|
| IF...THEN...ELSE | IF condition THEN [statements] ELSE [statements] | Two-way conditional decision branching based on boolean evaluation |
| SELECT CASE | SELECT CASE test_expression CASE val1: ... CASE ELSE: ... END SELECT | Multi-way selective branching cleanly replacing multiple nested IFs |
| FOR...NEXT | FOR counter = start TO end STEP increment [statements] NEXT counter | Deterministic count-controlled loop for repeating code a fixed number of times |
| WHILE...WEND | WHILE condition [statements] WEND | Pre-tested condition loop executing statements as long as condition evaluates True |
| DO...LOOP | DO WHILE condition ... LOOP or DO ... LOOP UNTIL condition | Versatile pre-test or post-test loop supporting WHILE and UNTIL clauses |
Section B: Standard Solved QBASIC Programs
Program 1Program 1: Generate the Multiplication Table of a Number
Write a QBASIC program to display the multiplication table of an input number up to 10.
CLS
INPUT "Enter an integer: ", n%
PRINT "Multiplication Table for"; n%
PRINT "-------------------------"
FOR i% = 1 TO 10
PRINT n%; " x "; i%; " = "; n% * i%
NEXT i%
END
Program 2Program 2: Reverse a Number and Check for Palindrome
Write a QBASIC program to reverse a positive integer and determine if it is a Palindrome.
CLS
INPUT "Enter a positive integer: ", n&
temp& = n&
rev& = 0
WHILE temp& > 0
rem% = temp& MOD 10
rev& = rev& * 10 + rem%
temp& = temp& \ 10
WEND
PRINT "Reversed Number = "; rev&
IF n& = rev& THEN
PRINT n&; " is a Palindrome Number."
ELSE
PRINT n&; " is NOT a Palindrome Number."
END IF
END
Program 3Program 3: Check Prime Number
Write a QBASIC program to check whether a given integer is Prime or Composite.
CLS
INPUT "Enter an integer greater than 1: ", num%
IF num% <= 1 THEN
PRINT "Number must be greater than 1."
END
END IF
count% = 0
FOR i% = 1 TO num%
IF num% MOD i% = 0 THEN count% = count% + 1
NEXT i%
IF count% = 2 THEN
PRINT num%; " is a Prime Number."
ELSE
PRINT num%; " is a Composite Number."
END IF
END
Program 4Program 4: Generate the Fibonacci Series up to 10 Terms
Write a QBASIC program to generate the first 10 terms of the Fibonacci sequence: 0, 1, 1, 2, 3, 5, 8, ...
CLS
a% = 0
b% = 1
PRINT "First 10 terms of Fibonacci Series:"
PRINT a%; b%;
FOR i% = 3 TO 10
c% = a% + b%
PRINT c%;
a% = b%
b% = c%
NEXT i%
END
Section C: String Handling in QBASIC
String FunctionsBuilt-in String Functions
| Function | Syntax | Returned Output | Example Call |
|---|---|---|---|
| LEN | LEN(str$) | Returns total count of characters in string | LEN("NEPAL") -> 5 |
| LEFT$ | LEFT$(str$, n) | Extracts n characters from leftmost side | LEFT$("KATHMANDU", 4) -> "KATH" |
| RIGHT$ | RIGHT$(str$, n) | Extracts n characters from rightmost side | RIGHT$("KATHMANDU", 5) -> "MANDU" |
| MID$ | MID$(str$, pos, n) | Extracts n characters starting at character position pos | MID$("POKHARA", 2, 3) -> "OKH" |
| UCASE$ / LCASE$ | UCASE$(str$) | Converts all letters to uppercase or lowercase | UCASE$("nepal") -> "NEPAL" |
String ProgramProgram: Reverse a Given Word and Check Palindrome String
Write a program to input a word and check if it is a palindrome string (e.g. MADAM).
CLS
INPUT "Enter a word: ", w$
w$ = UCASE$(w$)
rev$ = ""
FOR i% = LEN(w$) TO 1 STEP -1
rev$ = rev$ + MID$(w$, i%, 1)
NEXT i%
PRINT "Reversed word = "; rev$
IF w$ = rev$ THEN
PRINT "The word is a Palindrome String."
ELSE
PRINT "The word is NOT a Palindrome String."
END IF
END
Frequently asked questions
What is Programming in QBASIC about?
Complete textbook solutions and programming guide for Class 10 Computer Science Unit 9 Programming in QBASIC, covering variable suffixes, control flow (IF, SELECT CASE, loops), built-in string functions, and full solved programs for prime numbers, palindromes, and Fibonacci series.
Which topics are covered in Programming in QBASIC?
Class 10 Computer Science “Programming in QBASIC” covers: QBASIC Variable Suffixes: $, %, &, !, #; Conditional Branching: IF...THEN...ELSE, SELECT CASE; Looping Constructs: FOR...NEXT, WHILE...WEND, DO...LOOP; String Functions: LEN, LEFT$, RIGHT$, MID$, UCASE$; Classic Algorithms: Palindromes, Primes, Factorials.
What should I focus on in Programming in QBASIC for the exam?
Writing complete bug-free QBASIC programs for palindrome numbers, prime checking, multiplication tables, and string manipulations using MID$ and LEN.
What are the key formulas or definitions in Programming in QBASIC?
Integer Modulo: n MOD 10 extracts last digit; n \ 10 removes last digit.
Where can I read the Class 10 Computer Science “Programming in QBASIC” solutions?
Right on this page. They are free and you do not need to sign up. For chapter quizzes and the AI tutor, install the Sikshya Plus app.
Study tips
Do not just read it. Practice it.
You have read the solutions for Programming in QBASIC. Now test yourself, ask the AI tutor and keep your streak going.




- AI quizzes for this chapterTest yourself with instant feedback and explanations after every answer.
- AI tutor, free, 24/7Stuck on a question? Ask in your own words and get a step-by-step explanation.
- 14 AI tools in one appSummarizer, grammar checker, flashcards, essay help, math solver and more.
- Past questions and notesPast papers and your own notes organized chapter by chapter.