Category: Computer Programs

Basic Program To Print Square of Odd Not Even

REM THIS IS SQUARE OF ODDS NOT EVEN
CLS
SUM = 0
FOR F = 1 TO 100
LET X = 2 * F – 1
LET D = X * X
PRINT D;
NEXT F
END

Basic Program To Print Sum of Square of First N Odd Numbers

REM SUM OF FIRST N ODD NOS., SUM OF SQU OF FIRST N ODD NOS..?
CLS
SUM = 0
FOR I = 1 TO 10
LET A = 2 * I – 1
LET A = A * A
LET SUM = SUM + A
PRINT A, SUM
NEXT I
PRINT ” SUM”; SUM
END

Basic Program To Modifying A String

REM MODIFYING A STRING
CLS
P$ = “PROGRAMMING IN BASIC IS INTERESTING”
V$ = LEFT$(P$, 11)
C$ = ” ”
D$ = RIGHT$(P$, 14)
F$ = V$ + C$ + D$
PRINT F$
END

Basic Program To Insert Space Between Two Strings

REM INSERT SPACE BETWEEN TWO STRINGS
CLS
INPUT ” ENTER ANY STRING”; A$
V$ = LEFT$(A$, 11)
C$ = ” ”
D$ = RIGHT$(A$, 13)
F$ = V$ + C$ + D$
PRINT F$
END

Basic Program To Print Sum of First 100 Odd Numbers

REM SUM OF FIRST 100 ODD NUMBERS
CLS
SUM = 0
FOR F = 1 TO 100
LET SUM = SUM + 2 * F – 1
NEXT F
PRINT SUM
END

Basic Program To add Two Strings, Print it and its Length

REM ADD TWO STRINGS PRINT IT AND ITS LENGTH
CLS
10 LET A$ = “MICRO”
20 LET B$ = “COMPUTER”
40 GOSUB 100
50 PRINT C$
60 PRINT D
70 END
100 C$ = A$ + B$
120 D = LEN(C$)
130 RETURN

Basic Program To Calculate Percentage

10 CLS
30 DIM SUB$(6)
35 INPUT ” ENTER THE SUBJECT”; SUB$(1)
40 INPUT ” MARKS”; M(1)
41 INPUT “ENTER THE SUB”; SUB$(2)
42 INPUT “ENTER THE MARKS”; M(2)
43 INPUT “ENTER THE SUB “; SUB$(3)
44 INPUT “ENTER THE MARKS”; M(3)
45 INPUT “ENTER THE SUB”; SUB$(4)
46 INPUT “ENTER THE MARKS”; M(4)
47 INPUT “ENTER THE SUB”; SUB$(5)
48 INPUT “ENTER THE MARKS”; M(5)
49 INPUT “ENTER THE SUB”; SUB$(6)
50 INPUT “ENTER THE MARKS”; M(6)
51 CLS
100 LET M = M(1) + M(2) + M(3) + M(4) + M(5) + M(6)
160 CLS
170 LET PERCENT = M / 600 * 100
200 PRINT “TOTAL MARKS”; M
210 PRINT “% OF MARKS”; PERCENT
220 END

Basic Program To Tell the Given Number is Even or Odd

REM THE PROG TELLS IF THE GIVEN NUMBER IS EVEN OR ODD. TAKE THE NUMBER
REM DIVIDE IT BY TWO. REMAINDER IS EITHER 0 OR 1.ONCE AGAIN Q TIMES 2
REM SHOULD BE REMOVED FROM NUMBER. IF REMAINDER IS ONE THEN IT IS ODD AS
REM IT IS NOT FULLY DIVISIBLE BY 2
CLS
10 INPUT ” ENTER THE NUMBER”; N
20 FOR I = 1 TO INT(N / 2)
30 N = N – 2
40 NEXT I
50 IF N = 1 THEN PRINT “THE GIVEN NUMBER IS ODD” ELSE PRINT “THE NUMBER IS EVEN”
60 END

Basic Program To Tell Who is above 90% Merit Student

REM THIS PROGRAMME TELLS WHO IS ABOVE 90% MERIT STUDENT
CLS
1 O: INPUT ” ENTER NUMBER OF STUDENTS IN THE CLASS”; S
20 : FOR I = 1 TO S
30 : INPUT ” ENTER STUDENT NAME “; S$
40 : INPUT “ENTER STUDENT ROLL NO “; R
45 : INPUT “ENTER THE STUDENT CLASS”; N
50 : INPUT “STUDENT MATHEMATICS NO “; M
60 : INPUT “ENTER STUDENT SCIENCE NO “; S
70 : INPUT “ENTER STUDENT HINDI NO “; H
80 : INPUT “STUDENT ENGLISH NO “; E
90 : INPUT “STUDENT COMPUTER NO “; C
100 : T = M + S + H + E + C
110 : IF T > 450 THEN 120 ELSE 140
120 : PRINT S$; ” ROLL NUM”; R; ” CLASS”; N; ” A1 YOU ARE IN MERIT”
130 : GOTO 160
140 : PRINT S$; ” ROLL NUM”; R; “CLASS”; N; ” A2 YOU ARE NOT MERIT”
150 : GOTO 160
160 : NEXT I
170 : END

Basic Program To Print Sum of First N Odd and Even Numbers

REM SUM OF FIRST N ODD AND EVEN NUMBERS USING GOSUB AND RETURN
CLS
10 INPUT “ENTER ANY VALUE(N)”; N
20 GOSUB 100
30 GOSUB 200
40 PRINT “SUM OF ODD NUM”; SUM1
50 PRINT “SUM OF EVEN NUM”; SUM2
60 END
100 SUM1 = 0
110 FOR I = 1 TO N
120 X = 2 * I – 1
130 SUM1 = SUM1 + X
140 NEXT I
150 RETURN
200 SUM2 = 0
210 FOR I = 1 TO N
220 X = 2 * I
230 SUM2 = SUM2 + X
240 NEXT I
250 RETURN