User Profile

Collapse

Profile Sidebar

Collapse
aryucc
aryucc
Last Activity: Sep 18 '07, 03:11 PM
Joined: Sep 18 '07
Location:
  •  
  • Time
  • Show
  • Source
Clear All
new posts

  • aryucc
    replied to #INF00 ocurrs when cal. sum=(n/2)*(2*a+(n-1)*d)
    in C
    that means i have to do it like the followings:

    Code:
    { float sum, n, a, d, l;//n=no of term, a=first term, d=different, l=last term
    d=1, a=1, l=100, n=l-a+1;
    sum=(n/2)*(2*a+(n-1)*d);  
    printf("The sum of the numbers from %f to %f is %f.", a, l, sum);
    right???

    thz so much....
    See more | Go to post

    Leave a comment:


  • aryucc
    started a topic #INF00 ocurrs when cal. sum=(n/2)*(2*a+(n-1)*d)
    in C

    #INF00 ocurrs when cal. sum=(n/2)*(2*a+(n-1)*d)

    Code:
    #include <stdio.h>
    int main()
    { float sum, n, a, d, l;
    n=l-a+1, d=1, a=1, l=100;
    sum=(n/2)*(2*a+(n-1)*d);  
    printf("The sum of the numbers from %f to %f is %f.", a, l, sum);
        
        fflush(stdin);
        printf("\n\nPlease press Enter to continue......");
        getchar ();
        return 0;
    }

    it is calculating 1+2+3+...+100=s um...
    See more | Go to post
No activity results to display
Show More
Working...