To display product of digits
CLS
INPUT "Enter any number ";N
P=1
WHILE N< >0
R= N MOD 10
P=P*R
N= N\10
WEND
PRINT "Product of digits";P
END
Friday, October 11, 2019
QBaic Programming
To display sum of digits
CLS
INPUT "Enter any number";N
S=0
WHILE N < >0
R= N MOD 10
S= S+R
N=N\10
WEND
PRINT "Sum of digit";S
END
CLS
INPUT "Enter any number";N
S=0
WHILE N < >0
R= N MOD 10
S= S+R
N=N\10
WEND
PRINT "Sum of digit";S
END
QBasic Programming
To display greatest among 3 numbers
CLS
INPUT "Enter any three number"; A,B,C
IF A>B and B>C THEN
PRINT "The greatest number is";A
ELSE IF B>A and B>C THEN
PRINT "The greatest number is ";B
ELSE
PRINT "The greatest number is";C
END IF
END
CLS
INPUT "Enter any three number"; A,B,C
IF A>B and B>C THEN
PRINT "The greatest number is";A
ELSE IF B>A and B>C THEN
PRINT "The greatest number is ";B
ELSE
PRINT "The greatest number is";C
END IF
END
QBasic Programming
To display odd or even
CLS
INPUT" Enter any number ";N
IF N MOD 2=0 THEN
PRINT "The number is even"
ELSE
PRINT "The number of odd"
END IF
END
CLS
INPUT" Enter any number ";N
IF N MOD 2=0 THEN
PRINT "The number is even"
ELSE
PRINT "The number of odd"
END IF
END
QBasic Programming
To find the positive, negative or zero
CLS
INPUT "Enter any number ";N
IF N >0 THEN
PRINT "The number is positive "
ELSE IF N < 0 THEN
PRINT "The number is negative "
ELSE
PRINT "The number is zero "
END IF
END
CLS
INPUT "Enter any number ";N
IF N >0 THEN
PRINT "The number is positive "
ELSE IF N < 0 THEN
PRINT "The number is negative "
ELSE
PRINT "The number is zero "
END IF
END
QBasic Programming
To find the volume of cylinder
CLS
INPUT "Enter radius";r
INPUT "Enter height";h
V=22/7*r^2*h
PRINT "Volume of cylinder ";V
END
CLS
INPUT "Enter radius";r
INPUT "Enter height";h
V=22/7*r^2*h
PRINT "Volume of cylinder ";V
END
QBasic Programming
To find the volume of cube
CLS
INPUT " Enter length";l
V=l^3
PRINT "Volume of cube";V
END
CLS
INPUT " Enter length";l
V=l^3
PRINT "Volume of cube";V
END
Subscribe to:
Posts (Atom)