Friday, October 18, 2019

Qbasic programs

1) Wap to find area of rectangle.

》CLS
INPUT " Enter length ";l
INPUT " Enter breadth ";b
A = l * b
PRINT " Area of rectangle =";A
END


2) Wap to find area of circle.

 》CLS
INPUT " Enter radius ";r
A = 22/7  * R ^ 2
PRINT " Area of circle =";A
END


3) Wap to find a area of square.

》CLS
INPUT " ENTER LENGTH ";L
A = L ^ 2
PRINT " Area of square =";A
END

4) Wap to find a area of triangle.

》CLS
INPUT " Enter base ";b
INPUT " Enter height ";h
A = 1/2 * b * h
PRINT " Area of triangle =";A
END

5) Wap to find volume of cylinder.

》CLS
INPUT " Enter radius ";r
INPUT " Enter height ";h
V = 22/7 * 7 * r ^ 2 * h
PRINT " Volume of cylinder =";V
END


6) Wap to find input percentage and display pass or fail.

》CLS
INPUT " Enter percentage ";p
If p > = 40 THEN
PRINT " Pass "
Else
PRINT " fail "
END

7) Wap to input any number and check odd or even.

》CLS
INPUT " Enter any number ";n
If N MOD 2 = 0 THEN
PRINT " Even nuber "
ELSE
PRINT " Odd number "
END IF
END

8) Wap to input any number and check positive or negative or zero.

》CLS
INPUT " Enter any number ";n
If n  > o THEN
PRINT " Positive number "
ElSE IF n < o to THEN
PRINT " Negative number "
ELSE
PRINT " Zero "
END IF
END

9) Wap to input any number and check whether it is divisible by 5 or not.

》CLS
INPUT " Enter any number ";n
If n MOD 5 = o THEN
PRINT " The number is divisible by 5 "
ELSE
PRINT " The number is not divisibly by 5 "
END

10) Wap to display 5, 10, 15 .....50.

》CLS
FOR I = 5 to 50 STEP 5
PRINT I
NEXT I
END

11) Wap to display 100, 90, 80,....... 10.

》CLS
I = 100
WHILE I = 10
PRINT I
I = I - 10
WEND
END

12) Wap to display 2, 4, 6, 8,.... 20.

》 CLS
I = 2
DO WHILE I < = 20
PRINT I
I = I + 2
LOOP
END

13) Wap to display 50, 45, 40,..... 5.

》 CLS
I  = 50
WHILE I > = 5
PRINT I
I = I - 5
WEND
END

No comments:

Post a Comment