help us please

how to make a program in c of sum of N consecutive integers..
> example output
( 1+2=3+3=6+4=10+5=15 )

Comments

  • : how to make a program in c of sum of N consecutive integers..
    : > example output
    : ( 1+2=3+3=6+4=10+5=15 )
    :


    We are not here to do your homework for you. Ask a specific question or post the code you are having trouble with.
  • : : how to make a program in c of sum of N consecutive integers..
    : : > example output
    : : ( 1+2=3+3=6+4=10+5=15 )
    : :
    :
    :
    : We are not here to do your homework for you. Ask a specific question or post the code you are having trouble with.
    :

    Lazy people, if you mean some static integer stored in you program, then you could do something like

    int main(void)
    {
    printf("

    :>%d

    ", 1+2+3+4);
    }

    If you mean from a range you could use a couple of scanf statement and a for loop

    ie.

    int main(void)
    {
    int max, min;
    long sum = 0;
    puts("

    Type your minimum followed by space and you maximum.

    ");
    scanf("%d%d", &min, &max);
    int i;
    for (int i = min; i < max; ++ i)
    {
    sum+=i;
    }
    printf("

    Total is %d.

    ", sum)
    return sum;
    }

    pretty much you need to state more information about your homework.
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories