Go To Index
Computer Studies
Practical
Class IX (Arts /General /Humanities Group)
Practical No. 2: Write a program to calculate the SQUARE and CUBE of 1st ten Natural Numbers.PROGRAM:
10 CLS
20 PRINT “NUMBERS”, “SQUARE”, “CUBE”
30 PRINT “~~~~~~~~~”, “~~~~~~~~”, “~~~~”
40 FOR N = 1 TO 10
50 PRINT N, N^2, N^3
60 NEXT N
70 PRINT STRING$(35, “~”)
80 END
RUN
OR
10 REM CALCULATE SQUARE AND CUBE OF FIRST TEN NATURAL NUMBERS
20 CLS
30 PRINT TAB(5) "NUMBERS", "SQUARES", "CUBE"
40 FOR N = 1 TO 10
50 LET S = N^2
60 LET C = N^3
70 PRINT TAB(5) N, S, C
80 NEXT N
90 END
OUTPUT
NUMBER | SQUARES | CUBE |
---|---|---|
1 | 1 | 1 |
2 | 4 | 8 |
3 | 9 | 27 |
4 | 16 | 64 |
5 | 25 | 125 |
6 | 36 | 216 |
7 | 49 | 343 |
8 | 64 | 512 |
9 | 81 | 729 |
10 | 100 | 1000 |
No comments:
Post a Comment