+ 3
Guys i need help with c++
How can i write a program that reads 2 integers and add the even numbers between them?
10 ответов
+ 2
First of all your logic is not properly implemented.
int e=x; gives error becuase you need to give value to x before assinging..
&& with if() not a proper syntax... And some more..
Ok see this code
int main()
{
int x,y,sum=0;
cout<<"enter 2 numbers";
cin>>x>>y;
if(x%2!=0)
x++;
while(x<=y)
{
sum=sum+x;
x=x+2;
}
cout<<"\nsum of even numbers between x and y is "<<sum;
}
input: 2 8
output: 20 //2+4+6+8=20
is it what you want?
+ 7
What have you tried so far?
+ 4
Think and Try to do self.
+ 3
Why don't you give it a try yourself first?
Study the tutorial for a bit, try everything out. Reread the notes you made when your teacher explained loops to you.
And then try to write that program and show us!
(If we see an honest attempt, we're likely to assist.)
+ 3
Then where is your problem show us.
+ 1
I already did that
+ 1
i’ll show u my program but i dont know why its not runing
+ 1
https://code.sololearn.com/ce848H9mt18W/?ref=app
this is my code guys
+ 1
thank yoh very much❤️