GW-Basic Programs

Practical: 1- Write a Program to Print even numbers from 1 to 40.
 
Program:
10       CLS
20      FOR B = 2 TO 40 STEP 2
      30      PRINT B
      40      NEXT  B
      50      END
Algorithm
Step 1  START
Step 2  STORAGE    B=2
Step 3  DECISION    IS B<= 40 IF
NOT THEN GO TO STEP 7
Step 4  COMPUTE    B=B+2
Step 5   PRINT
STEP 6  GOTO STEP 3
Step 7 END

Algorithm

Step 1  START
Step 2  INPUT      L , W
Step 3  COMPUTE   AREA= L * W
Step 4    PRINT   AREA
Step 5  END
Practical: 11: Write a program that can calculate the perimeter of the rectangular.

Program:
10    CLS
20     INPUT “Length …=”;L
30     INPUT  “Width …=”; W
40     PERIMETER=  2* ( L+W)
50     PRINT “ PERIMETER….. =”; PERIMETER
60     END
Algorithm

Step 1  START
Step 2  INPUT      L , W
Step 3  COMPUTE   PERIMETER = 2* ( L+W)
Step 4    PRINT   PERIMETER
Step 5  END

Practical: 12: Write a program that can calculate the square and cube of any number.

Program:
10    CLS
20     INPUT “ Enter any No..…=”; N
30     Sq = N*N
40     Cub= N^3
50     PRINT “ Square….. =”; Sq
60     PRINT “ Cube….. =”; Cub
70      END
Algorithm

Step 1  START
Step 2  INPUT      N
Step 3  COMPUTE   Sq = N*N
Step 4 COMPUTE   Cub = N^3
 Step5  PRINT   Sq ,Cub
Ste 
Practical: 13: Write a program that can convert temperature from Centigrade to Fahrenheit

Program:
10    CLS
20     INPUT “ Temperature in Centigrade :=”; C
30     F = 9/5* C+32
40     PRINT “Temperature in Fahrenheit =”; F
50     END
Algorithm

Step 1  START
Step 2  INPUT      C
Step 3  COMPUTE    F = 9/5* C+32
Step 4  PRINT        F
Step 5  END
Practical: 14: Write a program that can convert temperature from Fahrenheit to Centigrade

Program:
10    CLS
20     INPUT “ Temperature in  Fahrenheit  :=”; F
30     C = 5/9* ( F-32) 
40     PRINT “Temperature in Centigrade  =”; C
50     END
Algorithm

Step 1  START
Step 2  INPUT      F
Step 3  COMPUTE    C = 5/9* ( F-32)
Step 4  PRINT        C
Step 5  END
Practical: 15:  Write a program that can draw a Triangle.

Program:
10    CLS
20     SCREEN 2
30     LINE  (110,50)- (160,100) 
40     LINE  (60,100)- (160,100)
50     LINE  (110,50)- (60,100) 
60     END

Algorithm
Step 1      START
Step 2       PRINT SCREEN 2
Step 3       OUTPUT       LINE (110, 50) - (160,100) 
                                 LINE (60,100) - (160,100)
                                 LINE (110, 50) - (60,100) 

Step 4            END
Practical: 16:  Write a program that can draw a Rectangle.
Program:
10    CLS
20     SCREEN 2
30     LINE  (70,80)- (190,170),,B 
40        END
Algorithm
Step 1      START
Step 2       PRINT SCREEN 2
Step 3       OUTPUT       LINE (70, 80) - (190,170),, B 
Step 4       END
Practical: 17: Write a program that can add 15+ 30+20+325.

Program:
10    CLS
20     READ A,B,C,D
30     SUM= A+B+C+D 
40      PRINT “SUM OF 15,30,20 AND 325 IS…=”; SUM
50      DATA 15,30,20,325
60       END
Algorithm
Step 1      START
Step 2       STORAGE       A=1
Step 3       DECISION      IS A <=4, IF NOT THEN GOTO STEP 8 
Step 4       COMPUTE      A=A+1
 Step 5       COMPUTE     SUM = SUM +5^A
 Step 6        PRINT   5^A, SUM
 Step 7       GOTO STEP 3
Step  8        END
Practical: 18: Write a program that can print all odd numbers from 1 to 100.

Program:
10    CLS
20    FOR N = 1 TO 100 STEP 2
30    PRINT       N  
40     NEXT   N
50      END
Algorithm
Step 1      START
Step 2       STORAGE       N=1
Step 3       DECISION      IS N <=100, IF NOT THEN GOTO STEP 7 
Step 4       COMPUTE      N=N+2
 Step 5       PRINT            N
 Step 6        GOTO STEP 3
 Step 7        END
Practical: 19: Write a program that can print all even numbers from 2 to 100.

Program:
10    CLS
20    FOR  B =  2 TO 100 STEP 2
30    PRINT       B  
40     NEXT   B
50      END
Algorithm
Step 1      START
Step 2       STORAGE       B=2
Step 3       DECISION      IS B <=100, IF NOT THEN GOTO STEP 7 
Step 4       COMPUTE      B=B+2
 Step 5       PRINT            B
 Step 6        GOTO STEP 3
 Step 7        END
Practical:20:  program that can Print you name five times using FOR-NEXT Loop.

Program:
10    CLS
20    FOR   N =1 TO 5
30    PRINT    “GOD IS GREAT”
40     NEXT   N
50      END
Algorithm
Step 1      START
Step 2       STORAGE       N=1
Step 3       DECISION      IS N<=5, IF NOT THEN GOTO STEP 7 
Step 4       PRINT               GOD IS GREAT
 Step 5      COMPUTE       N=N+1
 Step 6        GOTO STEP 3
 Step 7        END

Practical:2 :Write a Program to add two numbers.

Algorithm

Step 1  START
Step 2  INPUT   N1 ,N2   B=2
Step 3  COMPUTE     SUM N1+N2
Step 4  PRINT  SUM
Step 5 END
Practical: 3: Write such program which can read six numbers and print their average.
Algorithm

Step 1  START
Step 2  INPUT       N1, N2, N3, N4, N5, N6
Step 3  COMPUTE     AVG=( N1+N2+N3+N4+N5+N6) /6
Step 4  PRINT             AVG
Step 5  END
Practical: 4: Write a program which can find the largest number of given three numbers.
Algorithm

Step 1  START
Step 2  INPUT       N1, N2, N3
Step 3  DECISION  IS N1> N2 AND N1 > N3 IF YES THEN  PRINT  N1
Step 4  DECISION  IS N2> N1 AND N2 > N3 IF YES THEN  PRINT  N2
Step  5 ELSE PRINT  N3
Step 6  END
Practical: 5: Write a program that can calculate the sum and average of four numbers.
Algorithm

Step 1  START
Step 2  INPUT       N1, N2, N3, N4
Step 3  COMPUTE     SUM= N1, N2, N3, N4
Step 4  COMPUTE   AVG= SUM/4
Step 5  PRINT  SUM,AVG
Step 6 END
Practical: 6: Write a program that can draw a circle in a square.
Program:
10    CLS
20     SCREEN 2
30      CIRCLE  ( 100,100), 50
40      LINE ( 168,35)- (472,165),,B
50      END
Algorithm

Step 1  START
Step 2  PRINT     SCREEN 2
Step

3  PRINT      CIRCLE
(100,100),50
Step 4  PRINT       LINE (168,35)- (472,165),,B
Step 5  END
Practical: 7: Write a program that can calculate the area of a circle.
Algorithm

Step 1  START
Step 2  INPUT    N=R
Step 3  COMPUTE   AREA =3.14*R*R
Step 4  PRINT          AREA
Step 5  END
Practical: 8: Write a program that can draw a circle.
Program:
10    CLS
20     SCREEN 2
30      CIRCLE  ( 100,100), 50
40      END
Algorithm

Step 1  START
Step 2  PRINT     SCREEN 2
Step

3  PRINT      CIRCLE
(1000,100),50
Step 4  END
Practical: 9: Write a program that can find the value of a solid cylinder
Algorithm

Step 1  START
Step 2  INPUT      R , H
Step 3  COMPUTE VOL= 3.14*R^2*H
Step 4    PRINT  VOL
Step 5  END
Practical:10: Write a program that can calculate the area of a rectangle
Practical:11: Write a program to show 1st ten odd numbers using while wend loop.

119 comments:

  1. good explanation,nice evironment i really appreciate u very much helpful for me.

    ReplyDelete
  2. www.programminginbasic.webs.com

    ReplyDelete
    Replies
    1. moved to:
      https://gwbasicprograms.webs.com/

      Delete
    2. Strange website! Be careful!

      Delete
  3. Do you want to get free amazingly cool programs including games. Each advance than previous. Click here http://adf.ly/1iLsXP

    ReplyDelete
  4. Your blog took me some decades back when I started learning computers.

    ReplyDelete
  5. I really like GW-BASIC and your blog took me back in time when I started learning GW-Basic.

    ReplyDelete
  6. Good GW Basic this is the very 1st programming language when i started learning programming i was as grad 5.

    ReplyDelete
  7. kindly some one share the program to get full name of any person and return the number of characters in his first name.

    ReplyDelete
    Replies
    1. 10 N$ = ""
      20 FN$ = ""
      30 D$ = " "
      40 DI = 0
      50 PRINT "Enter your full name: ";
      60 INPUT N$
      70 N$ = TRIM$(N$)
      80 IF N$ = "" THEN GOTO 200 END IF
      90 DI = INSTR(N$, D$)
      100 IF DI = 0 THEN
      110 FN$ = N$
      120 ELSE
      130 FN$ = MID$(N$, 1, DI)
      140 END IF
      150 PRINT "Number of characters in your first name [ ";
      160 PRINT FN$;
      170 PRINT " ] = ";
      180 PRINT LEN(FN$)
      190 GOTO 10
      200 END

      Delete
    2. I posted above code thinking some visitor may need it.
      I used following site for testing above code and there it was working fine.
      https://www.jdoodle.com/execute-yabasic-online

      Delete
    3. Mr.Khursheed can you tell me the program to print the smallest number using for/next statement and also using only one input statement

      Delete
    4. This comment has been removed by the author.

      Delete
    5. 10 cls
      20 input "enter your full name:",nm$
      30 nl = len(nm$)
      40 fl = 0
      50 for I = 1 to nl
      60 sc$ = mid$(nm$,I,1)
      70 if sc$ = " " then 90 else fl = fl + 1
      80 next I
      90 print "first name legth = ";fl
      100 end

      Delete
    6. On 90 I have mistakenly type "legth" instead of "length"
      But program still work fine because
      It is just a prompt string dialog

      Delete
    7. Open this link to see the snapshot of the code in action
      https://drive.google.com/file/d/1jsJL7Xb6iUGRLJOS02M-8aZj_Czhp9nX/view?usp=drivesdk

      Delete
  8. for further lectures please contact 0333 3322391

    ReplyDelete
  9. Hi u were shaded my life did u feel us another start i faded was it all my fantsy

    ReplyDelete
  10. This comment has been removed by the author.

    ReplyDelete
  11. This comment has been removed by the author.

    ReplyDelete
  12. *****
    ****
    ***
    **
    *
    by using read and data stament in gw basic

    ReplyDelete
    Replies
    1. 10 cls
      20 for I = 1 to 5
      30 read x$
      50 print x$
      60 next I
      70 data "*****","****","***","**","*"
      80 end

      Delete
    2. Open this link to see the snapshot of the code in action
      https://drive.google.com/file/d/125FvDmrPVkLO64t6MdLszRHLZeuEiPwJ/view?usp=drivesdk

      Delete
  13. can anyone tell me the program to print the smallest number using for/next statement and also using only one input statement

    ReplyDelete
  14. This comment has been removed by the author.

    ReplyDelete
  15. 10 CLS
    20 LET a = 0
    30 LET b = 0
    40 FOR I = 1 TO 10
    50 PRINT "Enter number: ";
    60 INPUT b
    70 IF b < a THEN
    80 a = b
    90 ENDIF
    100 NEXT I
    110 PRINT "Smallest number is: ";
    120 PRINT a
    130 END

    ReplyDelete
  16. Above code takes 10 number input from keyboard in FOR loop and then prints smallest number out of all 10 numbers just entered.
    If I understood your question correctly then hopefully code I posted in previous post will solve your problem.

    ReplyDelete
  17. wap to store2 in 'a' and 3 in 'b' and print the result of the equation
    Q=a2+b2+2ab

    ReplyDelete
  18. 10 let a = 2
    20 let b = 3
    30 let q1 = (a ^ 2) + (b ^ 2) + (2 * a * b)
    40 print "Result of Q=a^2+b^2+2ab = ", q1
    50 let q2 = (a * 2) + (b * 2) + (2 * a * b)
    60 print "Result of Q=a2+b2+2ab = ", q2

    ReplyDelete
  19. Ramkrishna Ganguly:
    If you are asking for (a Square + b Square + 2ab) then q1 is answer to your question otherwise q2 is answer to your question.

    ReplyDelete
  20. I think people are asking for solution for their home work etc.
    Therefore I will not post any more solution here.
    Thanks.

    ReplyDelete
  21. These Are Easy Baby Programs
    Try These Ones Mostly Made By Me
    www.gwbasicprograms.webs.com

    ReplyDelete
  22. write a programe to compute s value where s=1-1/3+1/5-1/7+.....1/x

    ReplyDelete
    Replies
    1. 10 cls
      20 s = 1
      30 input "enter x:",x
      40 state = -1
      50 for I = 3 to x step 2
      60 if state = -1 then 70 else goto 90
      70 s = s - (1/I)
      80 state = 1: goto 110
      90 s = s + (1/I)
      100 state = -1
      110 next I
      120 print s
      130 end

      Delete
    2. This is based on Daniyal yousaf's solution he posted on October 5, 2018 at 4:26 AM.
      ---
      10 CLS
      20 s = 1
      30 INPUT "Enter x: ",x
      40 state = 1
      50 FOR I = 3 to x STEP 2
      60 state = (state) * (-1)
      70 s = s + ((state) * (1/I))
      80 NEXT I
      90 PRINT s
      100 END

      Delete
    3. Here's the snapshot of code in action
      https://drive.google.com/file/d/1Vafz0OB_l4yYv6uVrKOzlQ23Pvqw8Ys3/view?usp=drivesdk
      Just open this link

      Delete
  23. write a program to input any number then determine if the number is odd or

    ReplyDelete
    Replies
    1. 10 CLS
      20 INPUT "ENTER NUMBER: ",X
      30 IF X MOD 2 = 0 THEN GOTO 40 ELSE GOTO 50
      40 PRINT X " is even." :END
      50 PRINT X " is odd."
      60 END

      Delete
  24. I need gwbasic compiler ?

    ReplyDelete
  25. Wap to print the following pattern using semicolon
    *
    ***
    *****

    ReplyDelete
    Replies
    1. Auto
      10 cls
      20 new
      30 rem
      40 print "*"
      50 print "***"
      60 print "*****"
      70 end

      Delete
  26. if you want to practice and learn Gwbasic
    Download this app from play store for your android

    https://play.google.com/store/apps/details?id=umairayub.gwbasic

    ReplyDelete
  27. how to bring multiple names in according to alphabetic order ? and how to take out the percentage of so many students to calculate their marks?

    ReplyDelete
    Replies
    1. This program shows how to sort names: https://github.com/udhos/basgo/blob/master/basparser-samples/bubble.bas

      Delete
  28. Sir algorithm to find zakat ka program.

    ReplyDelete
  29. Sir plz send krdein subah exam he.

    ReplyDelete
  30. very helpful blog
    how to make flow chart of sub routine

    ReplyDelete
  31. Write down a program which print reverse counting from 10 to 01 on screen

    ReplyDelete
  32. Can you plz tell a program for car parking system. Consisting of 1 dimensional array

    ReplyDelete
  33. Mr.Khursheed actually the program you have given above is bit difficult to understand.....
    I am a student of matriculation,obviously a beginner..so plz give a easy program getting full name of person and giving first name length.



    ReplyDelete
    Replies
    1. 10 cls
      20 input "enter your full name:",nm$
      30 nl = len(nm$)
      40 fl = 0
      50 for I = 1 to nl
      60 sc$ = mid$(nm$,I,1)
      70 if sc$ = " " then 90 else fl = fl + 1
      80 next I
      90 print "first name legth = ";fl
      100 end

      Delete
    2. See the code in action at link below
      https://drive.google.com/file/d/1jsJL7Xb6iUGRLJOS02M-8aZj_Czhp9nX/view?usp=drivesdk

      Delete
  34. Write a program to assign 5 numbers calculate total and average and print them

    ReplyDelete
  35. WRITE A PROGRAM TO GENERATE A 5 TIMES TABLE USING LET STATEMENT

    ReplyDelete
  36. Very good site, I found more programming commands for gw basic here than any where else.

    ReplyDelete
    Replies
    1. Write a program in gw basic to display four vegetables name in different zones.

      Please help me.

      Delete
  37. Write a program in gw basic to display four vegetables name in different zones.

    Please help me.

    ReplyDelete
  38. Write a program in gw basic to display four vegetables name in different zones.

    Please help me.

    ReplyDelete
  39. This comment has been removed by the author.

    ReplyDelete
  40. I am in search of a BASIC program which prints results of permutations and combinations of say "a","b","c","d","e".Taken all 5 together.
    Here Permutations are 120 and combinations are 3125 with repetitions.

    ReplyDelete
  41. I am in search of a BASIC program which prints results of permutations and combinations of say "a","b","c","d","e".Taken all 5 together.
    Here Permutations are 120 and combinations are 3125 with repetitions.Without using "SWAP" command.

    ReplyDelete
  42. Write a program to print and check whether the number is divisible by 7 or not

    Please ANSWER for this question

    ReplyDelete
  43. Write a program to print and check whether the number is divisible by 7 or not

    Please ANSWER for this question

    ReplyDelete
  44. Write a program to print and check whether the number is divisible by 7 or not

    Please ANSWER for this question

    ReplyDelete
    Replies
    1. 10 CLS
      20 INPUT "ENTER NUMBER: ",X
      30 IF X MOD 7 = 0 THEN GOTO 40 ELSE GOTO 50
      40 PRINT X " is divisible by 7." :END
      50 PRINT X " is not divisible by 7."
      60 END

      Delete
    2. 10 CLS
      20 INPUT "ENTER NUMBER: ",X
      30 IF X MOD 7 = 0 THEN GOTO 40 ELSE GOTO 50
      40 PRINT X " is divisible by 7." :GOTO 60
      50 PRINT X " is not divisible by 7."
      60 END

      Delete
    3. Because it is good to have one END per program

      Delete
  45. Wap to print twin prime number.

    ReplyDelete
  46. Write a programe to the series of N terms

    ReplyDelete
    Replies
    1. Do you want to write a program get a number N from a user then print numbers from 1 to that number N?

      Delete
  47. write a program which can calculate the square of any number

    ReplyDelete
    Replies
    1. 10 CLS
      20 INPUT "Enter number:", n
      30 s = n * n
      40 PRINT "saquare of "; n; " is "; s
      50 END

      Delete
    2. 10 CLS
      20 INPUT "Enter the number: ";P
      30 T=P*P
      40 PRINT "Square of "; n; "is" ;T
      50 END

      Delete
  48. Write a program of 10 students, subject and their marks

    ReplyDelete
  49. I hope it will be helpful for almost all peoples that are searching for this type of topic. I Think this website is best for such topic. good work and quality of articles. ๋จนํŠ€๊ฒ€์ฆ

    ReplyDelete
  50. RARARA KAKAKLAKA HAHAHA JAJAJA CHALA JA BOSRI KE

    ReplyDelete
  51. If we talk about printers first name comes in our head is Brother Printers, for latest and updated Drivers for Brother go to the Following Sites.

    solutions.brother.com/windows
    solutions.brother.com/windows
    solutions.brother.com/windows
    solutions.brother.com/windows

    ReplyDelete
  52. write a program to show the smallest number of a 1d array ????

    ReplyDelete
  53. Write a gw basic program to calculate whether the atm pin entered is correct or not

    ReplyDelete
  54. To find total average of 3 subjects and if avg is less than 35 display fail else display pass

    Anyone help me how to do it ๐Ÿฅบ

    ReplyDelete
  55. 3. Write a program to read five numbers and print either one of the two statements is given below.
    ALL NUMBER ARE EQUAL
    OR
    ALL NUMBER ARE NOT EQUAL

    ReplyDelete
  56. Please help me to solve numerical maths using GWBASIC . like: RK method, Simpsons, Trapezoidal, Eular, Bisection , NR method etc

    ReplyDelete
  57. What is the best compiler for gw basic. To make exe file

    ReplyDelete
  58. Thank you for your post, myself very happy to read it because it can give me more insight, thanks.Perfect Cut Vinyl

    ReplyDelete
  59. Juniors cart is the Largest Online Shopping Store in Pakistan for New born, Kids, and babies with largest variety of Baby Products.
    Online Baby Products
    New Born Baby Accessories

    ReplyDelete
  60. Gw basic progrqmmersDecember 29, 2022 at 9:25 AM

    Plsss help someone
    1) Write a gw basic program to input a sentence and print the five lettered words
    2) Wabp to input a sentence and print the palindrome words

    Can anyone first teach me how to extract words from a sentence and then do the programs

    ReplyDelete
  61. Write a basic program to input a sentence and print it's last word?

    ReplyDelete
  62. Very interesting, good job and thanks for sharing such a good blog. Your article is so convincing that I never stop myself to say something about it. You’re doing a great job. Keep it up and take a look at my article which will show you link to the Color Blindness Test. Color Blindness Test

    ReplyDelete
  63. write a program to find the average of three numbers

    ReplyDelete
    Replies
    1. 10 let a = 11
      20 let b = 45
      30 let c = 32
      40 let z = (a + b + c) / 3
      50 print "Average of a, b and c is "
      60 print z

      Delete