Computer Science, asked by krishnarjunkarmakar, 5 months ago

Write the program to calculate the following series in QBASIC:
1 + X²/3 + X³/4 + X⁴/5 + X⁵/6​

Answers

Answered by BrainlyProgrammer
2

Question:-

To print the following series

Series:-

  \sf1 +  \dfrac{ {x}^{2} }{3}  +  \dfrac{ {x}^{3} }{4}  +  \dfrac{ {x}^{4} }{5} ....nth \: \: term

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:-

  1. The program accepts the value of X from the user.
  2. Then it accepts No. of terms
  3. Now, the first term is 1 so I intialized s as 1 and run the loop from 2 to N terms
  4. The program calculates the sum
  5. I loop gets updated with +1
  6. Once I value becomes greater than value of N then loop terminates
  7. Sum gets printed
  8. The program ends
Similar questions