CLEAR DATA

#include <iostream>
#include <string>
using namespace std;

int main() {

int nmbr, nmbr2entr, r, e = 0, o = 0,se = 0,so = 0;
int Odd[1000];
int Even[1000];
string Y="Y"; string y="y"; string ans="ans";

do
{

cout << "How many numbers do you want to enter: ";
cin >>nmbr2entr;



for(int a=0; a<nmbr2entr;a++)
{
cout<< "Enter a number: ";
cin>> nmbr;
{
if(nmbr%2==0)
{ se = se + nmbr; }
else
{ so = so + nmbr; }
}

r = nmbr % 2;
if (r == 0) {
Even[e] = nmbr;
e++;
}
else {
Odd[o] = nmbr;
o++;
}

}

cout << "Sum of all even numbers is: "<<se<<endl;
cout << "Sum of all odd numbers is: "<<so<<endl;



cout<<"Another Transaction (y/n)?: ";
cin>>ans;
}
while( (ans==y) || (ans==Y) );

return 0;
}


CAN YOU HELP ME WITH THIS PROGRAM? IT'S RUNNING BUT I IF I REPEAT IT THE NUMBERS ENTERED BEFORE IS ADDED TO THE NEW ONE. HOW IS IT? HELP PLS. THANKS
What are the values of se and so before the for loop and why?


Note:
1. All caps is considered shouting and thus rude.
2. Code tags and proper indentation make like much easier.
Sorry for that sir. se is = to sum of even and so = sum of odd
Lets rephrase:
You do add to variables se and so in a for loop. You might repeat that for loop within the do while. What are the actual numbers stored in so and se right before the for loop starts?
If I enter "y" for yes for a repetition the numbers i entered on the next repetition is added to numbers that I entered before.
Yes, but what should be the actual numbers stored in so and se right before the for loop starts?

Hint: What are the numbers before the first time?
The user will input the number you want to enter. Then sample is if you enter 2. 1 "Enter Number:" will be out and you enter a number and 1 "Enter Number:" again and that is 2 numbers. Then the two entered numbers, odd are added and even are added together. Then if i'll repeat it using while loop the numbers inputted before added in the new entered numbers
1
2
3
4
5
6
7
8
int nmbr2entr, se = 0;

do
{
  cout << "How many numbers do you want to enter: ";
  cin >>nmbr2entr;

  for (int a=0; a<nmbr2entr;a++)

Once again, what is the value of "se" on the first time the execution reaches line 7?

What should the value of "se" be on every time the execution reaches line 7?
Topic archived. No new replies allowed.