Write QBASIC programs using loops and nested loops:
1. Write a program in QBASIC to enter any 50 numbers. Find the sum of even
positive and odd negative numbers separately.
2. Write a program in QBASIC to enter 20 different numbers from the console.
Display the maximum and the minimum number among the given set of numbers.
3. Write a program in QBASIC to enter any 50 numbers. Display the sum of all
the numbers ending with 3 and product of all the numbers which are divisible by 7 separately.
4 Write a program in QBASIC to enter a number and check whether it is perfect
or not. (A number is said to be perfect if the sum of factors including 1 and excluding
the number itself, is same as the original number.). For example, 6 is a perfect number.
5. Write a program in QBASIC to display the first 10 numbers of the fibonacci
series: 0, 1, 1, 2, 3, 5 up to 10 terms.
[Hint: Take first two numbers as 0 and 1. Now obtain the next number by adding
the previous two numbers. For example, 0+1=1,1 + 1 = 2,1 + 2 = 3 and so on.]
6. Write a program in QBASIC to display the colours in a Rainbow (VIBGYOR)
using READ-DATA statement.
7. Write a program in QBASIC to accept the marks obtained in all the subjects
in the final examination using READ-DATA statement. Display the subject.
along with the highest marks.
8. Write a program in QBASIC to display all prime numbers from 1 to 100.
9. Write a program in QBASIC to display the factorial of the numbers from 2 to 20.
(Hint: Factorial 10 = 10 * 9 * 8 * 1)
10. Write a program in QBASIC to display the name and the average runs made by a cricketer in a test match for both the innings. The program should run for all the players who have played in the team. The names and runs shall be the inputs.
Answers
Answered by
7
Explanation:
1; CLS
even_sum$=0
odd_sum$=0
FOR I = 0 TO 50
INPUT "read N numbers..", n(I)
NEXT I
FOR J = 1 TO 50
IF n(j)<0
THEN IF (-1)*n(j)%2==1
THEN odd_sum=odd_sum+n(j)
ELSE
IF n(j)%2=0
THEN even_sum=even_sum+n(j)
NEXT J
PRINT "EVEN POSITIVE NUMBERS SUM";even_sum
PRINT "ODD NEGATIVE NUMBERS SUM";even_sum
Answered by
2
thanks for your points.
Similar questions
Physics,
1 month ago
English,
1 month ago
Math,
2 months ago
Social Sciences,
2 months ago
Social Sciences,
8 months ago