Wap to find the sum of square of odd numbers upto 10 in qbasic?
Answers
Answered by
9
Language:
Qbasic
Program:
CLS
sum=0
FOR i =0 TO 10 STEP 2
sum=sum+i^2
NEXT i
PRINT I
END
Output:
Consider the attachment.
Explanation:
- Line 1: Cleans screen.
- Line 2: Initializes sum, the variable where we are gonna store the odd square's values.
- Line 3: Starts a loop of odd numbers.
- Line 4: Adds squared sum of that odd number in sum every time the loop runs.
- Line 5: Prints the final sum (out of the loop, the final value of sum).
- Line 6: Ends the loop.
Attachments:
![](https://hi-static.z-dn.net/files/d02/bcc063a3c34e4272edc349fdf99ce315.jpg)
![](https://hi-static.z-dn.net/files/dfc/ff6f858d39b93c316ded60dc8c1a69dc.jpg)
Similar questions
Physics,
3 months ago
Hindi,
3 months ago
Hindi,
6 months ago
English,
1 year ago
India Languages,
1 year ago