Small Basic Programs (Input and Display) - Std VII

Small Basic Programs – Input and Display
Small Basic Programs
(Input and Display)

1. Check Positive or Negative Number

TextWindow.Write("Enter a number: ")
num = TextWindow.ReadNumber()

If num >= 0 Then
  TextWindow.WriteLine("Positive Number")
Else
  TextWindow.WriteLine("Negative Number")
EndIf
    
Explanation:
This program takes a number as input from the user. It checks whether the number is positive or negative and displays the result on the screen.

2. Find Sum of Two Numbers

TextWindow.Write("Enter first number: ")
a = TextWindow.ReadNumber()

TextWindow.Write("Enter second number: ")
b = TextWindow.ReadNumber()

sum = a + b
TextWindow.WriteLine("Sum = " + sum)
    
Explanation:
This program accepts two numbers from the user, adds them, and displays the sum.

3. Find Largest of Two Numbers

TextWindow.Write("Enter first number: ")
a = TextWindow.ReadNumber()

TextWindow.Write("Enter second number: ")
b = TextWindow.ReadNumber()

If a > b Then
  TextWindow.WriteLine("First number is larger")
ElseIf b > a Then
  TextWindow.WriteLine("Second number is larger")
Else
  TextWindow.WriteLine("Both numbers are equal")
EndIf
    
Explanation:
This program takes two numbers as input, compares them, and displays the largest number.

Comments

Popular posts from this blog

Index Class V - Excel - ICT

Interactive Worksheet - Excel-V True or False- Quiz

Interactive Worksheet - Excel-V Fill-in-the-Blanks Quiz