getting statement not reached at z=s;

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • iitanil
    New Member
    • Aug 2014
    • 1

    #1

    getting statement not reached at z=s;

    #include <stdio.h>
    #include <stdlib.h>
    #include <math.h>
    double mycos(double x,double err)
    {
    double i,r,c,z,s,t,a,n ;
    s=1;c=2*n;n=1;
    while(2>1){
    {for(i=1,a=1;i< =c;++i){a=a*i;} }
    t=pow(-1,n)*(pow(x,c)/a);
    s=s+t;
    ++n;
    }
    z=(s);return (z);
    }
    int main()
    {
    double err,x,a,r,c,t,i ,z;
    printf("give x");
    scanf("%lf",&x) ;
    z=mycos(x,err);
    printf("%lf",z) ;
    }
  • weaknessforcats
    Recognized Expert Expert
    • Mar 2007
    • 9214

    #2
    This code:
    Code:
    while([B]2>1[/B]){
     {for(i=1,a=1;i<=c;++i){a=a*i;}}
     t=pow(-1,n)*(pow(x,c)/a);
    etc...
    2 is always greater then 1. You never leave the while loop.

    Comment

    Working...