how to combine this? help plz..

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • zewl
    New Member
    • Oct 2009
    • 9

    how to combine this? help plz..

    Code:
    #include<stdio.h>
    #include<math.h>
    
    int main(void)
    {
        float x;
        float k,result,sum;
        float result2,sum1=0;
        float x1;
        int i,n;
    
        printf("Please enter a value of x:");
        scanf("%f",&x);
    
      if(x>0&&x<=2)
    
        {result= sum+log10(x);
        sum=0;
    
        printf("%f",result);}
    
    
        else{
        printf("Please enter a value that more than 0 and less or equall than 2.");
        }
    
     return 0;
    }
    i want to insert this into above program because i want to print 2 different result..
    how to do it? ive tried many times but it always error at the else.

    Code:
    x1 = (x - 1);
    
    for( i = 1; i < n; i++)
    {
    k = ( (pow((x-1), (i+1)) )/ (i+1) );
    if( ((i+1) % 2) == 0)
    x1 -= k;
    else
    x1 += k;
    
    result2=(sum1+x1)/2.303;
    }
    
    printf("%f",result2);
    Last edited by Banfa; Oct 9 '09, 03:22 PM. Reason: Added [code] ... [/code] tags
  • Banfa
    Recognized Expert Expert
    • Feb 2006
    • 9067

    #2
    Do you mean you get a compile error on that line? If so post the errors.

    Comment

    • donbock
      Recognized Expert Top Contributor
      • Mar 2008
      • 2427

      #3
      I don't really understand what you're trying to insert or where you want to insert it. You say you get errors at the else; what are those errors?

      Comment

      • myusernotyours
        New Member
        • Nov 2007
        • 188

        #4
        Oh yes. And please do use code tags when you are posting code. It's so much more easier on the eyes.

        Regards,

        Alex.

        Comment

        Working...