Write a program in QBASIC for the following statements:
➢ Make a program to print the sum of square of even numbers.
➢ Write a program to print the series :1,4,9,16,25,… up to 10 terms.
➢ Write a program to print the series :2,9,28,65,… up to 10 terms.
➢ Write a program to print the series
a) 12345 b) @@@@@
23456 @@@@
34567 @@@
45678 @@
56789 @
Answers
Answered by
3
Code Language: QBASIC
Question 1:
- Program to print the sum of squares of even numbers
Code:-
CLS
PRINT "ENTER A LIMIT"
INPUT N
S=0
FOR I=1 TO N
PRINT "ENTER A NUMBER"
INPUT NUM
IF NUM MOD 2=0
S=S+(NUM*NUM)
NEXT I
PRINT "SUM OF SQUARES OF EVEN NUMBERS ="+S
END
____________________
Question 2:
- Program to print the following series
Series:
- 1,4,9,16...10th term
Code Logic:-
- Square of each numbers from 1 to 10
Code:-
CLS
FOR I=1 TO 10
PRINT I^I
NEXT I
END
____________________
Question 3:
- Program to print the following series
Series:
- 2,9,28,65...10th term
Code Logic:-
- 1 added to the cube of each number from 1 to 10
Code:-
CLS
FOR I=1 TO 10
PRINT I^3+1
NEXT I
END
_____________________
Question 4:-
- Program to print the following pattern
Pattern (a):-
12345
23456
34567
45678
56789
Code:-
CLS
FOR K=1 TO 5
FOR J=K TO K+4
PRINT J
NEXT J
NEXT I
END
____________
Pattern (b):
@@@@@
@@@@
@@@
@@
@
Code:-
CLS
FOR I=5 TO 1 STEP-1
FOR J= 1 TO I
PRINT "@"
NEXT J
NEXT I
END
_____________________
Similar questions