Ask your own question, for FREE!
Computer Science 22 Online
OpenStudy (smilie2015):

#include int main() { int lowerlimit,upperlimit,isum=0,even=0,odd=0,sum; cout<<"Enter the lower limit"; cin>>lowerlimt; cout<<"Enter the upper limit"; cin>>upperlimit; for(i=lowerlimit;i<=upperlimit;i++){ sum = i+sum; cout<

OpenStudy (smilie2015):

@pitamar plz help

OpenStudy (anonymous):

Just some hints from first glance: First I'd do `#include <iostream>` without the `.h` that's the way using C++ standard libraries (as opposed to C) Second, those libraries come with `std` namespace, means you have have to call the functions with `std::cin`, `std::cout` and such.. unless you compiler add it implicitly. A quickfix (OK for small programs, not recommended for big ones) is to add `using namespace std;` below the `#include` statement so: ```cpp #include <iostream>; using namespace std; ``` Third you forgot to print `endl` for ending the lines when you do `cout`. for example: ```cpp cout<<"Odd:"<<odd<<endl; ``` Now let me try to compile hehe

OpenStudy (anonymous):

Also from looking.. isn't the `isum=0` supposed to be `i=0`?

OpenStudy (smilie2015):

thx alot

OpenStudy (anonymous):

works?

OpenStudy (smilie2015):

there is still errors:(

OpenStudy (anonymous):

ye I just tried to compile, lemme see :)

OpenStudy (anonymous):

you have a typo at `cin>>lowerlimt` it supposed to be `cin>>lowerlimit` Also you do not have a closing `}` after line 15 it should be ``` if(sum % 2 == 0) { even++; } // <--- else { odd++; } ```

OpenStudy (anonymous):

oh ye, and in the code I copied you forgot a space after the `#include` it should be `#include <iostream>` not `#include<#iostream>`

OpenStudy (smilie2015):

22 1 C:\Dev-Cpp\Untitled57.cpp [Error] expected '}' at end of input

OpenStudy (anonymous):

post the code, too many changes lol

OpenStudy (smilie2015):

#include<iostream> using namespace std; int main() { int lowerlimit,upperlimit,i=0,even=0,odd=0,sum; cout<<"Enter the lower limit"; cin>>lowerlimit; cout<<"Enter the upper limit"; cin>>upperlimit; for(i=lowerlimit;i<=upperlimit;i++){ sum = i+sum; cout<<sum; if(sum % 2 == 0) { even++;} else { odd++; } cout<<"Even :"<<even<<endl; cout<<"Odd:"<<odd<<endl; }

OpenStudy (anonymous):

I got something working out of it here: ```cpp #include <iostream> using namespace std; int main() { int lowerlimit,upperlimit,i=0,even=0,odd=0,sum=0; cout<<"Enter the lower limit"; cin>>lowerlimit; cout<<"Enter the upper limit"; cin>>upperlimit; for(i=lowerlimit;i<=upperlimit;i++){ sum = i+sum; cout << sum <<endl; if(sum % 2 == 0) { even++; } else { odd++; } } cout<<"Even :"<<even<<endl; cout<<"Odd:"<<odd<<endl; } ```

OpenStudy (smilie2015):

thanks alot finally i got it:)

OpenStudy (anonymous):

sure no problem =)

Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!
Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!