100% found this document useful (1 vote)
9K views3 pages

Programing With GW-Basic

This document contains 7 programming examples in GW-Basic to demonstrate different programming concepts: 1) A program to calculate the factorial of a number. 2) A program to create a multiplication table for a given number. 3) A program to evaluate temperature and output the corresponding conditions. 4) A program to find the smallest of two numbers. 5) A program to perform arithmetic operations on two variables. 6) A program to check if a number is even or odd. 7) A program to calculate the sum of even and odd digits of a number.

Uploaded by

Khubbaib Naeem
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
100% found this document useful (1 vote)
9K views3 pages

Programing With GW-Basic

This document contains 7 programming examples in GW-Basic to demonstrate different programming concepts: 1) A program to calculate the factorial of a number. 2) A program to create a multiplication table for a given number. 3) A program to evaluate temperature and output the corresponding conditions. 4) A program to find the smallest of two numbers. 5) A program to perform arithmetic operations on two variables. 6) A program to check if a number is even or odd. 7) A program to calculate the sum of even and odd digits of a number.

Uploaded by

Khubbaib Naeem
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 3

Programming with GW-basic (10TH)

Page 1

Time 5:48:25 a6/p6

Program # 1 10 CLS: REM This program is used to find the factorial of Number 5 20 fact = 1 30 n = 5 40 WHILE (n >= 1) 50 fact = fact * n 60 n = n - 1 70 WEND 80 PRINT "factorial="; fact Program # 1(a) 10 CLS: REM This program is used to find the factorial of any Number 20 fact = 1 30 input please enter the value for finding factorial; n 40 WHILE (n >= 1) 50 fact = fact * n 60 n = n - 1 70 WEND 80 PRINT "factorial="; fact Program # 2 10 REM this program is used to find the table of any number 20 CLS 30 INPUT "please enter the value which you want to make a table"; t 40 INPUT "please enter the value for table length"; l 50 n = 1 60 WHILE (n <= l) 70 PRINT t; "*"; n; "="; t * n 80 n = n + 1 90 WEND Program # 3 Q:Write a program for following conditions If temperature is greater than 35 If temperature is between 25 to 35 If temperature is less than 25

Hot day Pleasant day Cool day

10 REM this program is used to make decision for temperature 20 CLS 30 INPUT "please enter the temperature"; t 40 IF (t > 35) THEN PRINT "hot day": END 50 IF (t >= 25) AND (t <= 35) THEN PRINT "pleasant day": END 60 IF (t < 25) THEN PRINT "cool day" 70 END Prepared By Khubbaib Best Of Luck

Programming with GW-basic (10TH) Program # 4 CLS 10 REM this program is used to fin smallest no 20 INPUT "please enter the value of a"; a 30 INPUT "please enter the value of b"; b 40 IF (a < b) THEN smallest = a ELSE GOTO 50 50 IF (b < a) THEN smallest = b 60 PRINT "The smallest value is"; smallest 70 END Out of the Program:Please enter the value of a? 12 Please enter the value of b? 10 The smallest value is 10

Page 2

Time 5:48:25 a6/p6

Program # 5 10 CLS 20 REM this program is used to perform all arithmetic operation on tow variables 30 INPUT "Please enter the value of a"; a 40 INPUT "Please enter the value of b"; b 50 INPUT "Please enter valid arithmetic operator"; op$ 60 IF (op$ = "+") THEN PRINT "Sum="; a + b ELSE GOTO 70 70 IF (op$ = "-") THEN PRINT "Subtract="; a - b ELSE GOTO 80 80 IF (op$ = "*") THEN PRINT "Multiply="; a * b ELSE GOTO 90 90 IF (op$ = "/") THEN PRINT "Division="; a / b ELSE GOTO 100 100 END Out of the Program:Please enter the value of a? 12 Please enter the value of b? 10 Please enter valid arithmetic operator? * Multiply =120 Program # 6 10 CLS 20 REM this program is used to find whether the number is even or odd 30 INPUT "Please enter the value for check the number"; n 40 IF (n MOD 2 = 0) THEN PRINT "This number is even" ELSE PRINT "This number is odd" 50 END

Prepared By Khubbaib Best Of Luck

Programming with GW-basic (10TH) Output:Please enter the value for check the number? 5 This number is odd Program # 7

Page 3

Time 5:48:25 a6/p6

10 CLS 20 oddsum = 0 30 evensum = 0 40 INPUT Please enter the number; n 50 WHILE (n >= 0) 60 IF (n MOD 2 = 0) THEN evensum = evensum + n ELSE oddsum = oddsum + n 70 n = n - 1 80 WEND 90 PRINT "The sum of even digit is="; evensum 100 PRINT "The sum of odd digit is="; oddsum Out put:Please enter the number? 5 The sum of even digit is=6 The sum of odd digit is=9

Prepared By Khubbaib Best Of Luck

You might also like