DASHAIN & TIHAR HOMEWORK
15 QBASIC PROGRAMMING
1. WAP TO FIND THE AREA OF RECTANGLE.
-> CLS
INPUT ''ENTER LENGTH'';L
INPUT ''ENTER BREADTH'';B
A = L * B
PRINT ''AREA OF RECTANGLE='';A
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 DISPLAY THE AREA OF TRIANGLE.
-> CLS
INPUT ''ENTER BASE'';B
INPUT ''ENTER HEIGHT'';H
A=1/2*B*H
PRINT ''AREAOF 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 ''EVENNUMBER''
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 ''NUMBER IS DIVSIBLE 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 EVEN NUMBERS FROM 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
A = L * B
PRINT ''AREA OF RECTANGLE='';A
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 DISPLAY THE AREA OF TRIANGLE.
-> CLS
INPUT ''ENTER BASE'';B
INPUT ''ENTER HEIGHT'';H
A=1/2*B*H
PRINT ''AREAOF 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 ''EVENNUMBER''
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 ''NUMBER IS DIVSIBLE 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 EVEN NUMBERS FROM 2 TO 40.
-> CLS
FOR I = 2 TO 40 STEP 2
PRINT I
NEXT I
END
Comments
Post a Comment