a program that prints sum of even/odd integers

Hello, I was wondering if anyone knew a program that would print the sum of the even integers from say.... 2 to 30

Comments

  • : Hello, I was wondering if anyone knew a program that would print the sum of the even integers from say.... 2 to 30
    :
    [green]
    Yep sure do as well as a lot of people on this board. What about it?
    [/green]

  • : : Hello, I was wondering if anyone knew a program that would print the sum of the even integers from say.... 2 to 30
    : :
    : [green]
    : Yep sure do as well as a lot of people on this board. What about it?
    : [/green]
    :
    :


    I'm not sure where to start...could you me out-
  • : : : Hello, I was wondering if anyone knew a program that would print the sum of the even integers from say.... 2 to 30
    : : :
    : : [green]
    : : Yep sure do as well as a lot of people on this board. What about it?
    : : [/green]
    : :
    : :
    :
    :
    : I'm not sure where to start...could you me out-
    :

    [green]
    Hammer out some code and then post problems here. I can't do your homework for you. You won't learn anything that way. It's not as hard as you think.
    [/green]


  • : : : Hello, I was wondering if anyone knew a program that would print the sum of the even integers from say.... 2 to 30
    : : :
    : : [green]
    : : Yep sure do as well as a lot of people on this board. What about it?
    : : [/green]
    : :
    : :
    :
    :
    : I'm not sure where to start...could you me out-
    :

    [blue]start here[/blue]
    [code]
    int main()
    {
    // put your code here


    return 0;
    }
    [/code]

  • : Hello, I was wondering if anyone knew a program that would print the sum of the even integers from say.... 2 to 30
    :

    Taking a basic approach

    declare a sum var and init it to 0
    loop through your desired range of values
    compare the current index using the modulus operator
    if the current index is even, then add its value to your old sum
    print the result
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