Write the program to calculate the following series in QBASIC:
1 + X²/3 + X³/4 + X⁴/5 + X⁵/6
Answers
Answered by
2
Question:-
To print the following series
Series:-
Code Logic:-
s=s+ (x^i)/(i+1). where s is initialized to 1
Code:-
CLS
PRINT "ENTER VALUE OF X"
INPUT X
PRINT "ENTER THE LIMIT"
INPUT N
S=1
FOR I=2 TO N
S=S+(X^I)/(I+1)
NEXT I
PRINT "SUM="+S
END
Code Explaination:-
- The program accepts the value of X from the user.
- Then it accepts No. of terms
- Now, the first term is 1 so I intialized s as 1 and run the loop from 2 to N terms
- The program calculates the sum
- I loop gets updated with +1
- Once I value becomes greater than value of N then loop terminates
- Sum gets printed
- The program ends
Similar questions