➽ Program:-

#include<iostream>

using namespace std;

int main()

{

    int i, number, even = 0, odd = 0;

    cout<<"Enter a Number: ";

    cin>>number;

 

    for(i = 1; i <= number; i++)

    {

        if(i % 2 == 0)

           even += i;

        else

           odd += i;   

    }

   

    cout << "Sum of all Even Numbers = " << even << endl;

    cout << "Sum of all Odd Numbers = " << odd << endl;

    return 0;

}

➽ Output:-

Enter a Number: 50
Sum of all Even Numbers = 650
Sum of all Odd Numbers = 625