Practice Questions:
IF Statement:
- Write a QBasic program to input a number and display “Positive Number” only if the number is
positive.
- Write a program to input the age of a person and display “Eligible to Vote” if age is 18 or above.
- Write a program to input a number and display “Even Number” if the number is divisible by 2.
- Write a program to input marks of a student and display “Pass” if marks are 40 or more.
- Write a program to input a character and display “Uppercase Letter” if the character is uppercase.
IF_ELSE Statement:
- Write a QBasic program to input a number and check whether it is even or odd.
- Write a program to input two numbers and display the greater number.
- Write a program to input the salary of an employee and check whether the employee is taxable or not
(tax
if salary > 50,000).
- Write a program to input temperature and display “Hot Day” or “Cold Day”.
- Write a program to input a number and check whether it is positive or negative.
IF_ELSE_IF Statement:
- Write a program to input marks and display division according to the rules: ≥80 Distinction, ≥60
First
Division, ≥45 Second Division, ≥32 Third Division, Else Fail
- Write a program to input a number and display whether it is positive, negative, or zero.
- Write a program to input age and display Child, Teenager, Adult, or Senior Citizen.
- Write a program to input a character and check whether it is a vowel, consonant, or invalid input.
- Write a program to input units of electricity consumed and calculate bill based on slabs using
IF…ELSEIF.
For_Next Statement:
- Write a QBasic program to display numbers from 1 to 10 using FOR…NEXT.
- Write a program to display the multiplication table of a given number.
- Write a program to find the sum of first 100 natural numbers.
- Write a program to display all even numbers between 1 and 50.
- Write a program to calculate the factorial of a given number.
Do_While Statement:
- Write a program to display numbers from 1 to 10 using DO WHILE.
- Write a program to display all odd numbers up to 50.
- Write a program to calculate the sum of digits of a number using DO WHILE.
- Write a program to reverse a given number using DO WHILE.
- Write a program to display numbers until the user enters 0.
While_Wend Statement:
- Write a program to display numbers from 10 to 1 using WHILE…WEND.
- Write a program to find the sum of natural numbers up to N.
- Write a program to count how many digits are in a given number.
- Write a program to check whether a given number is palindrome.
- Write a program to calculate the sum of even numbers between 1 and 100.
Nested For_Next Statement:
- Write a program to display the following pattern:
*
* *
* * *
* * * *
- Write a program to display numbers in matrix form:
1 2 3
4 5 6
7 8 9
- Write a program to display the multiplication tables from 1 to 2.
- Write a program to generate a number pyramid.
- Write a program to input marks of 5 students in 3 subjects and display the total marks of each
student.