Dashain and Tihar Homework
15 Qbasic programming
1. WAP to find the area of rectangle
CLS
INPUT " Enter Length";L
INPUT " Enter Breadth" B
Area = L*B
PRINT " Area of rectangle is= "; Area
END
2. WAP to display the area of circle.
CLS
INPUT "Enter radius";R
A = 22/7*R^ 2
PRINT "Area of circle=";A
END
3. WAP to display the area of square
CLS
INPUT "Enter length";L
A = L^2
PRINT "Area of square=";A
END
4. WAP to find the area of triangle.
CLS
INPUT "Enter breadth"; B
INPUT "Enter height"; H
A=1/2*H
PRINT "Area of triangle="; A
END
5. WAP to display 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
6. WAP to input percentage and display pass or fail
CLS
INPUT "Enter percentage";P
IF P>=40 THEN
PRINT "pass"
ELSE
PRINT "fail"
END IF
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 number"
ELSE
PRINT "odd number"
END IF
END
8. WAP to input any number and check positive, negative or zero
CLS
INPUT "Enter any number";N
IF N >0 THEN
PRINT "positive number"
ELSE IF N <0 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=0 THEN
PRINT "The number is divisible by 5"
ELSE
PRINT "The number is not divisible by 5"
END IF
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
14. WAP to print first 10 natural numbers
CLS
FOR I =1 to 10
PRINT I
NEXT I
END
15. WAP to print the even numbers frkm 2 to 40
CLS
FOR I=2 to 40 Step 2
PRINT I
NEXT I
END
1. WAP to find the area of rectangle
CLS
INPUT " Enter Length";L
INPUT " Enter Breadth" B
Area = L*B
PRINT " Area of rectangle is= "; Area
END
2. WAP to display the area of circle.
CLS
INPUT "Enter radius";R
A = 22/7*R^ 2
PRINT "Area of circle=";A
END
3. WAP to display the area of square
CLS
INPUT "Enter length";L
A = L^2
PRINT "Area of square=";A
END
4. WAP to find the area of triangle.
CLS
INPUT "Enter breadth"; B
INPUT "Enter height"; H
A=1/2*H
PRINT "Area of triangle="; A
END
5. WAP to display 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
6. WAP to input percentage and display pass or fail
CLS
INPUT "Enter percentage";P
IF P>=40 THEN
PRINT "pass"
ELSE
PRINT "fail"
END IF
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 number"
ELSE
PRINT "odd number"
END IF
END
8. WAP to input any number and check positive, negative or zero
CLS
INPUT "Enter any number";N
IF N >0 THEN
PRINT "positive number"
ELSE IF N <0 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=0 THEN
PRINT "The number is divisible by 5"
ELSE
PRINT "The number is not divisible by 5"
END IF
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
14. WAP to print first 10 natural numbers
CLS
FOR I =1 to 10
PRINT I
NEXT I
END
15. WAP to print the even numbers frkm 2 to 40
CLS
FOR I=2 to 40 Step 2
PRINT I
NEXT I
END
Comments
Post a Comment