Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

I need to use a for loop to create a program that calculatessine. I have to use

ID: 1815237 • Letter: I

Question

I need to use a for loop to create a program that calculatessine. I have to use the formula of x-x^3/3!+x^5/5!... I am havingtrouble grasping the for loop construct. Can anyone help meplease!? This is all I have so far x=input('Enter a value of x:'); N=input('Enter thenumber of terms'); for i=1:N SINE= I need to use a for loop to create a program that calculatessine. I have to use the formula of x-x^3/3!+x^5/5!... I am havingtrouble grasping the for loop construct. Can anyone help meplease!? This is all I have so far x=input('Enter a value of x:'); N=input('Enter thenumber of terms'); for i=1:N SINE= x=input('Enter a value of x:'); N=input('Enter thenumber of terms'); for i=1:N SINE=

Explanation / Answer

clear all

n=input('Enter thenumber of terms: ');

x=input('Enter avalue of x: ');

ssum=0;

sgn=-1;

for k=1:n

sgn=-sgn;

p=2*k-1;

v=1;

for m=1:p

v=v*m;

end

ssum = ssum + sgn*x^(p) /v;

end

ysum=ssum;

fprintf('%12.8f ',ysum)