Constant is a value in the computer memory which doesn't change
variable is a value in the computer memory which change
types of variable
numeric variable : we store number
string variable: we store names, text , address
Operator is sign which perform certain operations
operation be
- mathematical(+,-,*,/)
- logical(AND, OR, NOT)
- string(+)
- Relational Operator(<,>,=,<=,>=,<>(not equals to))
statements
CLS
REM
INPUT
PRINT
END
Syntax: the rule or the way in which program is written
IF ..... ELSE IF...... END
Syntax
IF <condition1>
print "this statement will be executed if condition1 is true"
ELSE IF <Condition2>
print "this statement will be executed if condition2 is true"
ELSE
PRINT "this line will be printed"
END IF
WRITE THE SYNTAX OF FOLLOWING STATEMENTS with one example
i) FOR … NEXT statement
ii) DO … LOOP statement
iii) WHILE … WEND statement
Program #1
Program to display first 100 natural numbers:
REM To display first 100 natural numbers
CLS
FOR i = 1 TO 100
PRINT i;
NEXT i
END
Program #2
Program to display the multiplication table of any supplied number:
REM To display the multiple tables of any supplied number
CLS
INPUT "Type any number "; n
c = 1
DO
PRINT n; "x"; c; "="; n * c
c = c + 1
LOOP WHILE c <= 10
END
C |
Output print “N x c”= N*c |
1 |
3x1=3 |
2 |
3x2=6 |
3 |
3x3=9 |
4 |
3x4=12 |
5 |
3x5=15 |
6 |
3x6=18 |
7 |
3x7=21 |
8 |
3x8=24 |
9 |
3x9=27 |
10 |
3x10=30 |
output
Type any number:3
3x1=3 |
3x2=6 |
3x3=9 |
3x4=12 |
3x5=15 |
3x6=18 |
3x7=21 |
3x8=24 |
3x9=27 |
3x10=30 |
Program #3
Program to check prime or composite
REM TO check prime or composite
CLS
INPUT "Type any number "; n
FOR i = 2 TO n - 1
IF n MOD i = 0 THEN c = c + 1
NEXT i
IF c = 0 THEN
PRINT "Prime"
ELSE
PRINT "Composite"
END IF
END
N=5
C=0
N |
i |
C=c+1 |
5 |
2 |
0 |
5 |
3 |
0 |
5 |
4 |
0 |
type any number :5
Prime
Program to check Armstrong or not:
REM To check Armstrong or not
CLS
INPUT "Type any number "; n
a = n
WHILE n < > 0
r = n MOD 10
s = s + r ^ 3
n = n \ 10
WEND
IF a = s
THEN
THEN
PRINT "Armstrong"
ELSE
PRINT "Not Armstrong"
END IF
END
Library Functions /Inbuild function
a) LEN () b) LEFT$ () c) RIGHT$ ()
d) MID$ ()
e) LCASE$ () f) UCASE$ ()
g) VAL () h) STR$ ()
i) ASC()
j) CHR$() i) SQR () j) FIX()
k) INT() l) LTRIM$ ()
Comments
Post a Comment