Home > Back-end >  Bosses have a look at my C language choice structure which has a problem? Can run, the output data.
Bosses have a look at my C language choice structure which has a problem? Can run, the output data.

Time:04-30

Topic and my program attached

CodePudding user response:

Post code, don't map,

CodePudding user response:

#include
The main ()
{
Float x;
Double a, b, c, min, sum;
Int the count, I, j, sign;
a=1; B=1; i=1; count=0; Sign=1; Sum=0;
Printf (" Input x: ");
The scanf (" % f ", & amp; x);
For (I=1;; I=I + 2)
{
for(j=1; j<=I; J++)
{
A=a * x;
B=b * j;
Min=a/b;
}
The sum +=sign x min;
Sign=(1) * sign;
count++;
If (min<1-5 e)
{
break;
}
The else
{
continue;
}
}
Printf (" sin (x)=% lf, count=% d \ n ", sum, count);
return 0;
}

CodePudding user response:

Reference:
 # include 
# include

Int main ()
{
Float x;
Double a, b, c, min, sum;
Int the count, I, j, sign;
count=0; Sign=1; Sum=0;//a=1; B=1; i=1;
Printf (" Input x: ");
The scanf (" % f ", & amp; x);
For (I=1;; I +=2) {//for (I=1;; I++)
a=1; B=1;
for(j=1; j<=I; J++) {
A *=x;
B *=j;
Min=a/b;
}
The sum +=sign x min;
Sign=(1) * sign;
count++;
If (fabs (min) & lt; 1 e - 5) break;
If (fabs (min) & gt; E=1-5) continue;
}
Printf (" sin (x)=% lf, count=% d \ n ", sum, count);

return 0;
}



//Input x: 10
//sin (x)=0.544022, count=18
//please press any key to continue...

CodePudding user response:

You choose the first for loop variable I do not have constraints, die run would be in circulation, the output

CodePudding user response:

Thank you thank you, I give it a try
  • Related