Q basic programming
1. Write a program that asks in any subject and display the message "Result pass" if the input is greater than 40.
CLS
INPUT "ENTER MARKS IN COMPUTER"; C
IF C>=40
THEN PRINT "RESULT PASS" ELSE PRINT"RESULT FAIL"
END
2. Write a program that asks two numbers and display the greater one.
CLS
INPUT "ENTER ENTER FIRST NUMBER"; A
INPUT "ENTER SECOND NUMBER"; B
IF A>B THEN
PRINT "THE GREATER NUMBER IS"; A
ELSE
PRINT "THE GREATER NUMBER"; B
END IF
END
3. Write a program that checks whether the supplied number is even or odd.
CLS
INPUT "ENTER FIRST NUMBER"; A
IF N MOD 2 = 0 THEN
PRINT "EVEN NUMBER'"
ELSE
PRINT "ODD NUMBERS"
END IF
END
4. Write a program that asks two numbers and displays the difference between greater and smaller number.
CLS
INPUT "ENTER FIRST NUMBER"; A
INPUT "ENTER SECOND NUMBER"; B
IF A>B THEN
D = A - B
ELSE
D = B - A
END IF
PRINT "DIFFERENCE OF GREATER AND SMALLER NUMBER="; D
END
5. Write a program to print smallest among 3 numbers.
CLS
INPUT "ENTER ANY THREE NUMBERS" A, B, C
IF A<B AND B<C THEN
PRINT "THE SMALLEST NUMBER IS"; A
ELSEIF B<A AND B<C THEN
PRINT "THE SMALLEST NUMBER"; B
ELSE
PRINT "THE SMALLEST NUMBER IS"; C
END IF
END
6. Write a program that asks your age and tells whether you are eligible to vote or not.
CLS
INPUT "ENTER YOUR AGE="; A
IF A>= 18 THEN
PRINT "YOU ARE ELIGIBLE TO VOTE"
ELSE
PRINT "YOU ARE NOT ELIGIBLE TO VOTE"
END IF
END
7. Write a program that asks marks in 3 subjects and display message pass or fail.
CLS
INPUT "ENTER MARKS IN THREE SUBJECT"; A, B, C
IF A>=40 AND B>=40 AND C>=40 THEN
PRINT "YOU ARE PASS"
ELSE
PRINT "YOU ARE FAIL"
END IF
END
8. Write a program using FOR....NEXT statement to print natural numbers up to 15.
CLS
FOR I = 1 TO 15
PRINT I
NEXT I
END
9. Write a program using FOR...NEXT statement to print first 10 odd numbers.
CLS
FOR I = 1 TO 20 STEP 2
PRINT I
NEXT I
END
10. Write a program using FOR...NEXT statement to print even numbers from 2 to 20.
CLS
FOR I = 2 TO 20 STEP 2
PRINT I
NEXT I
END
11. Write a program using FOR...NEXT statement to generate numbers 2, 5, 8, 11 ...32
CLS
FOR I = 2 TO 32 STEP 3
PRINT I
NEXT I
END
12. Write a program using FOR...NEXT to print; 100, 95, 90....5
CLS
PRINT I 100 TO 5 STEP -5
PRINT I
NEXT I
END
13. Write a program to print sum of even numbers from 2 to 10.
CLS
FOR I = 2 TO 10
S = S + I
NEXT I
PRINT "SUM="; S
END
14. Write a program to print sum of first 15 natural numbers.
CLS
FOR I = 1 TO 15
S = S + I
NEXT I
PRINT "SUM="; S
END
15. Write a program to print sum of odd numbers from 1 to 21.
CLS
FOR I = 1 TO 21 STEP 2
S = S + I
NEXT I
PRINT "SUM="; S
END
16. Write a program to first 10 natural numbers.
CLS
P = 1
FOR I = 1 TO 1O
P = P * I
NEXT I
PRINT "PRODUCT="; P
END
17. Write a program to print even numbers from 20 to 40.
CLS
FOR I = 20 TO 40 STEP 2
PRINT I
NEXT I
END
18. Write a program to print numbers; 1, 8, 27......100
CLS
FOR I = 1 TO 10
PRINT I^3
NEXT I
END
19. Write a program to generate multiplication table of input number.
CLS
INPUT "ENTER ANY NUMBER"; N
FOR I = 1 TO 10
PRINT N;"X"I;"="; N*I
NEXT I
END
Comments
Post a Comment