0% found this document useful (0 votes)
14 views

Basic Programming 5th Sem

The document contains instructions for writing basic programming code to solve various problems. It includes 22 programming challenges ranging from finding the largest side of a triangle to calculating Fibonacci numbers. The document provides the problem statement and expected line number for the code for each challenge. It also includes introductions to basic programming concepts like commands, data types, and programming languages.

Uploaded by

bikramnath0677
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
14 views

Basic Programming 5th Sem

The document contains instructions for writing basic programming code to solve various problems. It includes 22 programming challenges ranging from finding the largest side of a triangle to calculating Fibonacci numbers. The document provides the problem statement and expected line number for the code for each challenge. It also includes introductions to basic programming concepts like commands, data types, and programming languages.

Uploaded by

bikramnath0677
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 25

GoVT.

DEGREE COLLEGE
LLE 3E

R,NORTH
DHARMANAGAR,
TRIPURA

PHYSICs DEPARTMENT

TOPIC : BAsIC PROGRAMMING


NAME :KANAK PRIYA SAHA
_TH
5 SEMESTER (PASS)

SUBJECT: PHYSICS PRACTICAL

ROLL NO. : 2015000137


REGISTRATION O: 2020-014501
BASIC PROGRAMMING

INDEX

PAGE
SL CONTENTS REMARKS
No. No.

INTRODUCTION 3 to 5

Write a program in BASIC to find the largest side of a


triangle where the three sides are given as input. 6
1 First of all you have to check whether the three sides
form atriangle and then yOu have to find the largest
side.
Write a program in BASIC to find the area of a triangle
using Heron's formula. The three sides are given as a
2 input. First of all you have to check whether the three
area
sides form a triangle and then you have to find the
of the triangle.
Write a program in BASIC to check whether a right
angle triangle is possible bythe three sides given as
3 input. First of all you have to check whether the three
sides can form a triangle and then you have to check
the condition for right angle triangle.
4
Write a program in BASIC to input an integer and print
all its divisors at the output.
Write a program in BASIC to input 10 random 10
numbers. Print all the odd numbers at the output.
6
Write a program in BASIC to input 10 random 11
numbers. Print all the even numbers at the output.
Write a BASIC tofind al the prime numbers from 1 to 12
7
100.
Write a program in BASIC to calculate the sum of 10 13
natural numbers.
"N"
Write a program in BASIC to calculate factorial of 14
where N is given as input.
10
Write a program in BASIC to input two numbers and 14
calculate their L.C.M.

11
Write a program in BASIC to input two numbers and 15
calculate their H. C.F.

12
Write a program in BASICto input 10 numbers and 16
print the numbers at the output in ascending order.

EXAA
BASIC PROGRAMMING

SL PAGE
CONTENTS REMARKS
No. No.
13
Write a program in BASIC to input 10 numbers and 17
print the numbers at the output in descending order.
Write aprogram in BASIC to input 10 numbers and
14 arrange the number in reverse order in two columns at 18
the output.
Write a program in BASIC to print 10 Fibonacci 19
15
numbers at the output where T(1)=0and T(2)=1
16 Write a program in BASIC to input a temperature in 19
Celsius scale and convert it into Fahrenheit scale.
Write a program in BASIC to input a temperature in 20
17 Fahrenheit scale and convert it into a Celsius scale.
Write a program in BASIC to input radius of a sphere 20
18
incentimetre and caiculate its area and volume.
Write a program in BASC to input a five-digit number.
19
Construct a new number where the digits are arranged 21
in reverse order and print both five digits numbers as
output.
Write a program in BASIC to input the focal length of a
20 convex lens. If the object distance is given. Calculate 21
the image distance.
Write a program in BASIC to input a five digit number.
Construct a new number where the digits are arranged 22
21
in ascending and descending order and print both five
digit numbers as output.
22
Write a program in BASIC to input five resistance when 23
they are in parallel combination.
23
Write a program in BASIC to print first 10 terms of the 23
following series. 0,3, 8, 15,24,35..
24
Write a program in BASIC to input the numbers of days 24
and convert it into year, month and day.
Write aprograrn in BASIC tofind all three digit
25
numbers for which sum of the cube of the digits is 24
equal to the numbers itself
e.g.,153=13+5°+33 (Armstrong number)

Page |2
BASIC PROGRAMMING

INTRODUCTION
BASIC (an acronym for Beginner's All-purpose symbolic instruction Code) is family of
general purpose, high level programming languages whose design philosophy
emphasis ease of use.
In 1964, John G. Kemeny and Thomas E Kurtz designed the original Basic language
at Dartmouth College in new Hampshire. They wanted to enable students in fields
other than science and mathematics to use computers required writing custom
software,which was something only scientists and mathematicians tended to learn.
BASIC :Basic is a high level language. It was developed in 1964, itquickly becomes
one of the most popular language for general purpose use and scientific
applications.

Keyfeatures of BASIC:

> It is an easy user-friendly language


> It is general purpose language and can be used for business and scientific
applications
> It has simple syntax rules and is easy to test and debug.
> It has English like structure
> It is best for students

Types of entries in BASIC

There are three different types entries in Basic


These are:

> Commands
Program statements
> Data

Commands are executable instruction such as SAVE, LOAD, LIST etc. They are
generally executable in direct mode.

Numeric Data (type) include e.g. 12, +2.67,-23.4 etc.


String Data (type) include words or test. Astring consists of characters, special
character or numeric.

Page | 3
BASIC PROGRAMMING

Programming language :
called
function of a computer is controlled bya set of instructions
The to tell the computer,
computer program. These instructions are written
What operation to perform?
Where to locate the data?

How to present data?

computer instruction known as the


The language used on the communication of
programming languages.

Three level of programming language are available. They are


a) Machine language (Low level language)
b) Assembly level language or symbolic language
c) High level language

Page | 4
BASIC PROGRAMMING

SOME MPORTANT COMMANDS:

Commands Functions
running it to any new
After typing one program and before
NEW. By the command
program, one has to use the command
can be displayed on the
NEW
NEW, new line number 1,2,3.. .....
Screen of monitor.
the screen of the monitor.
CLS The command is used to clear
generate line number.
AUTO The command is used to automatically
the program
This command is used to list allor part of
LIST
currently in memory.
program file from disc into
This command is used to load a
LOAD
main memory.
of file from specified
This command is used to display the list
FILES
drive.
allows the user to
The full form is REMARK. This statement
ignore. It is a
REM type any information which the computer will
non-excitable command.
currently in
This command is used to excite the program
RUN
memory.
be store in
Using the command save the correct program can
SAVE
secondary storage.
The stop statement terminate the program execution before
STOP the end of the program unit.
This command is used to remember the program lines in RAM.
RENUM
GOTO This statement go to transfer the control to the line numbers.
This command is used to edit specified program line currently
EDIT
in memory.
It is the end state of a sub program and causes the transfer of
RETURN
control to the main program.
When a program is not required any more, one can erase the
KILL program from the disk using this command.
DELETE If wants to delete aprogram that is currently in memory.
GOSUB This statement transfer control to specified line number.
END It is last command of a program which terminates a program.
This command is used to exit from GW-BASIC and return the
SYSTEM
operating system.

Page | 5
BASIC PROGRAMMING

1. Write a program in BASIC to find the largest side of a triangle where


the three sides are given as input. First of all you have to check
whether the three sides form a triangle and then you have to find the
largest side.
1 CLS
2 INPUT"ENETR ANY THREE SIDES:";A, B,C
3 IF (A+B) >C AND (B+C) >A AND (C+A) >B THEN
4 PRINT" TRIANGLE CAN BE FORMED"
5 GOTO 10
6 ELSE
7 PRINT" TRIANGLE CANNOT BE FORMED"
8 END IF
9 GOTO 19
10 IF A>=B AND A>=C THEN
11 PRINT" GREATEST SIDE IS=" ;A
12 END IF
13 IF B>=A AND B>=C THEN
14 PRINT" GREATEST SIDE IS=" ;B
15 END IF
16 IF C>=A AND C>=B THEN
17 PRINT"GREATEST SIDE IS=" ;C
18 END IF
19 GOTO 2
20 END

AFTER RUN
ENETR ANY THREE SIDES:5
??6
???4
TRIANGLE CAN BE FORMED
GREATEST SIDE IS=6
ENETR ANY THREE SIDES : 1
??5
???9
TRIANGLE CANNOT BE FORMED
ENETR ANY THREE SIDES :

Page 6
BASIC PROGRAMMING

2. Write a program in BASIC to find the area of a triangle using


Heron's formula. The three sides are given as a input. First of all you
have to check whether the three sides form a triangle and then you
have tofind the areaof the triangle.
1 CLS
2 INPUT"ENTER THREE SIDES:";A, B, C
3 IF (A+B) >C AND (B+C) >A AND (C+A) >B THEN
4 PRINT"TRIANGLE CAN BE FORMED"
5 GOTo 10
6 ELSE
7 PRINT"TRIANGLE CANNOT BE FORMED"
8 GOTO 13
9 END IF
10 S= (A+B+C) /2
11 R= (S* (S-A) * (S-B) * (S-C) ) ^ (1/2)
12 PRINT"AREA OF THE TRIANGLE=";R
13 GOTO 2
14 END

AFTER RUN
ENTER THREE SIDES:3
??4
???5
TRIANGLE CAN BE FORMED
AREA OF THE TRIANGLE=6
ENTER THREE SIDES:1
??2
???3
TRIANGLE CANNOT BE FORMED
ENTER THREE SIDES:

Page 7
BASIC PROGRAMMING

3. Write a program in BASIC to check whether a right angle triangle is


possible by the three sides given as input. First of all you have to
check whether the three sides can form a triangle and then you have
to check the condition for right angle triangle.
1 CLS
2 INPUT"ENTER THREE SIDES: ";A, B, C
3 IF (A+B) >C AND (B+C) >A AND (C+A) >B THEN
4 PRINT"TRIANGLE CAN BE FORMED"
5 GOTO 10
6 ELSE
7 PRINT"TRIANGLE CANNOT BE FORMED"
8 GOTO 14
9 END IF
10 IF (A^2) +(B^2) = (C^2)OR (B^2)+(C^2) =(A^2) OR (C^2) +(A^2) =(B^2)
THEN
11 PRINT"RIGHT ANGLE TRIANGLE CAN BE FORMED"
12 ELSE
13 PRINT"RIGHT ANGLE TRIANGLE CANNOT BE FORME D"
14 END IF
15 GOTO 2
16 END

AFTER RUN
ENTER THREE SIDES:3
??4
???5
TRIANGLE CAN BE FORMED
RIGHT ANGLE TRIANGLE CAN BE FORMED
ENTER THREE SIDES: 4
??5
???6
TRIANGLE CAN BE FORMED
RIGHT ANGLE TRIANGLE CANNOT BE FORMED
ENTER THREE SIDES:

Page | 8
BASIC PROGRAMMING

4. Write a program in BASIC to input an integer and print all its


divisors at the output.
1 CLS
2 INPUT"ENTER ANY
3 IF N=0 THEN INTEGER:";N
4 PRINT"EVERY INTEGER ARE DIVISOR OF ZERO"
5 GOTO 11
6 END IF
7 PRINT "DIVISORS OF ";N;" ARE"
8 FOR I=1 TO N
9 IF N MOD I=0 THEN
10 NEXT
PRINTI
11 GOTO 2
12 END

AFTER RUN
ENTER ANY INTEGER :0
EVERY INTEGER ARE DIVISOR OF ZERO
ENTER ANY INTEGER:8
DIVISORS OF 8 ARE
1
2
4
8
ENTER ANY INTEGER:7
DIVISORS OF7 ARE
1
7
ENTER ANY INTEGER:

Page | 9
BASIC PROGRAMMING

5. Write a program in BASIC to input 10 random numbers. Print all the


odd numbers at the output.
1 CLS
2 PRINT"ENTER 10 RANDOM NUMBERS"
3 FOR I=l TO 10
4 INPUT A(I)
5 NEXT
6 PRINT""
7 PRINT"ODD NUMBERS ARE"
8 FOR I=1 TO 10
9 IF A (I) MOD 2<>0 THEN PRINT A(I)
10 NEXT
11 END

AFTER RUN
ENTER 10 RANDOM NUMBERS
?4
?5
?1
26
?3
?8
?5
?7
?9
22

ODD NUMBERS ARE

2l04/es
Page | 10
BASIC PROGRAMMING
6. Write aprogram in BASIC to input 10
even numbers at the random numbers. Print all the
output.
1 CLS
2
3
PRINT"ENTER 10
FOR I=l TO 10 RANDOM NUMBERS"
4 INPUT A(I)
5 NEXT
6 PRINT""
7
8
PRINT"EVEN NUMBERS
FOR I=1 TO 10
ARE"
9 IF A (I) <>0 AND A (I)
MOD 2=0 THEN PRINT A (I)
10 NEXT
11 END

AFTER RUN
ENTER 10 RANDOM NUMBERS
?1
?4
?7
?2
?5
?8
?3
?6
?9
?6

EVEN NUMBERS ARE


4

Page | 11
BASIC PROGRAMMING

7. Write a BASIC to find all the prime numbers fromn 1 to 100.


1 CLS
2 PRINT"PRIME NUMBER FROM 1 TO 100"
3 FOR I=2 TO 100
4 C=0
5 FOR J=l TO I
6 IF I MOD J=0 THEN LET C=C+1l
7 NEXTJ
8 IF C=2 THEN PRINT I
9 NEXT I
10 END

AFTER RUN
PRIME NUMBER FROM 1 TO 100

5
7
11
13
17
19
23
29
31
37
41
43
47
53
59
61
67
71
73
79
83
89
97

Page | 12
BASIC PROGRAMMING

8. Write a program in BASIC to calculate the sum of 10natural


numbers.
1 CLS
2 PRINT"ENETR 10 NATURAL NUMBERS"
3 FOR I=1 TO 10
4 INPUT A(I)
5 NEXT
6 LET P=0
7 FOR I=1 TO 10
8 P=A (I) +P
9 NEXT
10 PRINT" SUM=";P
11 END

AFTER RUN
ENETR 10 NATURAL NUMBERS
?64
?56
?52
?51
?23
?89
?23
?213
?657
?35
SUM=1263

Page | 13
BASIC PROGRAMMING

9. Write a program in BASIC to calculate factorial of "N" where Nis


given as input.
1 CLS
) INPUT"ENTER ANY NUMBER=";N
3 LET F=l
4 FOR I=1 TO N STEP 1
5 F=F*I
6 NEXT
7 PRINT"FACTORIAL OF ";N; " IS : ";F
8 GOTO 2
9 END

AFTER RUN
ENTER ANY NUMBER=3
FACTORIAL OF 3 IS : 6
ENTER ANY NUMBER=5
FACTORIAL OF 5 IS: 120
ENTER ANY NUMBER=

and calculate their


10. Write a program in BASIC to input two numbers
L.C.M.
1 CLS
2 INPUT"ENTER ANY TWO NUMBER=";A,B
3 M=A
4 N=B
5 WHILE A<>0
6 R=B MOD A
7 B=A
8 A=R
9 WEND
10 L=(M*N) /B
11 PRINT"L.C.M=";L
12 GOTO 2
13 END

AFTER RUN
ENTER ANY TWO NUMBER=9
??6
L.C.M=18

Page | 14
BASIC PROGRAMMING

11. Write a program in BASIC to input two numbers and calculate thelr
H.C.E.
1 CLS
TNPUT"ENTER ANY TWO NUMBER=";A,B
3 M=A
4 N=B
5 WHILE A<>0
6 R=B MOD A
7 B=A
8 A=R
9 WEND
10 PRINT"H.C.F=";B
11 GOTO 2
12 END

AFTER RUN
ENTER ANY TWO NUMBER=5
??6
H.C.F=l
ENTER ANY TWO NUMBER=6
??8
H.C.F=2
ENTER ANY TWO NUMBER=

Page | 15
BASIC PROGRAMMING

12 Write aprogranm in BASIC to input 10 numbers and print the


numbers at the output in ascending order.
1 CLS
"ENTER ANY 10 NUMBERS"
2 PRINT
34FOR I=l TO l0
INPUT A(I)
5 NEXT
TO 10
6 FOR I=1 10
7FOR J= (I+l) TO
THEN
8 IF A(I) >A(J)
(I)
9 LET MAX=A
=A (J)
10 LET A(I)
11 LET A(J) =MAX
12 END IF
13 NEXT J
14 NEXT I
15 PRINT!"
16 PRINT"ASCENDING ORDER IS"
17 FOR I=1 TO 10
18 PRINT A(I)
19 NEXT
20 END

AFTER RUN
ENTER ANY 10 NUMBERS
?21
?56
?453
?654
?21
?56
?6547
289
?1654
28912

ASCENDING ORDER IS
21
21
56
56
89
453
654
1654
6547
8912

Page | 16
BASIC PROGRAMMING

13. Write a program in BASIC to input 10numbers and print tne


numbers at the output in descending order.
1 CLS
2 PRINT"ENTER ANY 10
3 FOR I=1 TO 10
NUMBERS"
4 INPUT A(I)
5 NEXT
6 FOR I=1 TO 10
7 FOR J= (I+1) TO 10
8 IF A (I)<A(J) THEN
9 LET MAX=A(I)
10 LET A(I) =A(J)
11 LET A(J) =MAX
12 END IF
13 NEXT J
14 NEXT I
15 PRINT"
16 PRINT" DESCENDING ORDER IS"
17 FOR I=1 TO 10
18 PRINT A(I)
19 NEXT
20 END

AFTERRUN
ENTER ANY 10 NUMBERS
?6
?54
?21
?65
?789
?3254
?6587
?2
?75
?562

DESCENDING ORDER IS
6587
3254
789
562
75
65
54
21
6
2

Page | 17
BASIC PROGRAMMING
14. Write a program in BASIC to
input 10 numbers and arrange the
number in reverse order in two columns at the
1 CLS output.
2
PRINT"ENTER ANY 10
3 FOR I=1 TO 10 NUMBER"
4 INPUT A(I)
5 NEXT
6 PRINT"REVERSE ORDER
7 FOR I=1 TO 10 ORIGINAL ORDER"
8 PRINT" ";A(1+10-I);"
9 NEXT ";A(I)
10 END

AFTER RUN
ENTER ANY 10 NUMBER
?213
?5
?65
?7
?98
?32
?0
?53
?21
?16
REVERSE ORDER ORIGINAL ORDER
16 213
21 5
53 65
7
32 98
98 32
7
65 53
5 21
213 16

Page 18
BASIC PROGRAMMING

45. Write a program in BASIC to print 10 Fibonacci numbers at the


output where T(1)=0 and T(2)=1
1 CLS
2 A=0
3 B=1
4 PRINT "T (1) =";A
5 PRINT "T (2) =";B
6 FOR I=3 TO 10
7 C=A+B
8 A=B
9 B=C
10 PRINT"T (";1;") =";C
11 NEXT
12 END

AFTER RUN
T(1) =0
T(2) =1
T(1)=l
T(1)=2
T (1) =3
T(1) =5
T(1) =8
T(1)=13
T(1)=21
T (1) =34

temperature in Celsius scale


16. Write a program in BASIC to input a
and convert it into Fahrenheit scale.
1 CLS
CELCIUS:";C
2 INPUT"ENTER TEMP IN
3 F= (9*C/5) +32
FAHRENHEIT:";F
4 PRINT"TEMP IN
5 END

AFTER RUN
ENTER TEMP IN CELCIUS : 32
TEMP IN FAHRENHEIT:89.6

Page | 19
BASIC PROGRAMMING

17. Write a program in BASIC to input a


scale and convert it into a Celsius scale. temperature in Fahrenheit
1 CLS
2 INPUT"ENTER TEMP IN
3 C=5* (F-32) /9 FAHRENHE IT:";E
4 PRINT"TEMP IN
5 END
CELCIUS: ";C

AFTER RUN
ENTER TEMP IN FAHRENHE IT:332
TEMP IN CELCIUS:
166.666667

18. Write a program in BASICto input radius of a sphere in


centimetre and calculate its area and volume.
1 CLS
2 INPUT"THE RADIUS OF A
SPHERE: ";R
3 A=4*3.14*R^2
4 V=4/3 *3.14 *R^3
5 PRINT"AREA:";A, "VOLUME : ";V
6 END

AFTER RUN
THE RADIUS OF A SPHERE:7
AREA:615.44 VOLUME:1436.02667

Page | 20
BASIC PROGRAMMING

19. Write a program in BASC to input a five-digit number. Construct a


new number where the digits are arranged in reverse order and print
both five digits numbers as output.
1 CLS
2 INPUT "ENETR ANY5 DIGIT
3 LET A=N
NUMBERS:";N
4 IF N<10000 OR N>99999 THEN
5 PRINT "INVALID INPUT"
6 GOTO 2
7 END IF
8 S=0
9 WHILE N>0
10 R=N MOD 10
11 S=l0*S+R
12 N=INT (N/10)
13 WEND
14 PRINT"REVERSE ORDER" ; "SAME ORDER"
15 PRINT " ";S;" ":A
16 END

AFTER RUN
ENETR ANY 5 DIGIT NUMBERS: 65483
REVERSE ORDER SAME ORDER
38456 65483

20. Write a program in BASIC to input the focal length of a convex


lens. If the object distance is given. Calculate the image distance.
1 CLS
2 INPUT"ENTER FOCAL LENGTH, F=";F
3 INPUT"ENTER OBJECT DISTANCE, U =";U
4 V=(U*F) / (U+F)
5 PRINT "IMAGE DISTANCE, V=";V
6 END

AFTER RUN
ENTER FOCAL LENGTH, F=23
ENTER OBJECT DISTANCE, U =10
IMAGE DISTANCE, V=6.96969697

Page | 21
BASIC PROGRAMMING

21. Write a program in BASIC to input a


new number where the digits are five digit number. Construct a
arranged in ascending and
descending order and print both five digit numbers as output.
1 CLS
2
INPUT"ENTER
3 IF
FIVE DIGIT NUMBER:";N
N<10000 OR N>99999 THEN
4 PRINT"INVALID INPUT"
5 GOTO 2
6 END IF
7 I=1
8 WHILE N>0
9 R=N MOD 10
10 A(I) =R
11 N=INT (N/10)
12 I=l+ I
13 WEND
14 FOR I=1 TO 5
15 FOR J= (I+1) TO 5
16 IF A(I)>A(J) THEN
17 MAX=A (I)
18 A(I)=A(J)
19 A(J) =MAX
20 END IF
21 NEXT J
22 NEXT I
23 PRINT"ASCENDING ORDER"
24 FOR I=1 TO 5
25 PRINT A(I)
26 NEXT
27 PRINT"
28 PRINT"DESCENDING ORDER"
29 FOR I=1 TO 5
30 PRINT A(6-I);
31 NEXT
32 END

AFTER RUN
ENTER FIVE DIGIT NUMBER: 4586
INVALID INPUT
ENTER FIVE DIGIT NUMBER:86952
ASCENDING ORDER
25689
DESCENDING ORDER
98652

Page | 22
BASIC PROGRAMMING
22. VWrite a program in BASIC to
parallel combination. input five resistance when they are in
1 CLS
2
PRINT"ENTER
3 FOR I=l TO 5
ANY FIVE
RESISTANCES"
4 INPUT A(I)
5 NEXT
6 LET P=0
7 FOR I=1 TO 5
8 P=(I/A(I)) +P
9 NEXT
10
PRINT"EQUIVALENT RESISTANCES, R="; 1/P
11 END

AFTER RUN
ENTER ANY FIVE
?6 RESISTANCES
?4
?9
?8
?2
EQUIVALENT RESISTANCES, R=0.25

23. Write a program in BASICto print first 10 terms of the following


series. 0,3, 8, 15, 24,35.....
1 CLS
2 FOR I=1 TO 10
3 R= (I^2) -1
4 PRINT R; ", ";
5 NEXT
6 END

AFTER RUN
0,3,8,15,24, 35, 48, 63, 80, 99,

Page | 23
BASIC PROGRAMMING

24. Write a program in BASIC to input the numbers of days and


convert it into year, month and day.
1 CLS
2 INPUT "NUMBER OF DAYS: ";N
3 Y= INT (N/365)
4 MO=N MOD 365
5 M=INT (MO/30)
6 D=MO MOD 30
7 PRINT Y;"-YEARS ";M;"-MONTHS "; D;"-DAYS"
8 END

AFTER RUN
NUMBER OF DAYS:9845
26-YEARS 11-MONTHS 25-DAYS

25. Write a program in BASIC to find all three digit numbers for which
sum of the cube of the digits is equal to the numbers itself
e.g.,153=1'+5'+3° (Armstrong number)
1 CLS
2 FOR I=100 TO 999
3 S=0
4 A=I
5 P=I
6 WHILE A>0
7 R=A MOD 10
8 S=St+R^3
9 A=INT (A/10)
10 WEND
11 IF P=S THEN PRINT S
12 NEXT I
13 END

AFTER RUN
153
370
371
407

24|0|2
Page | 24

You might also like