🔒 Locked
Help... please!
Advertisement
Original Post
You forgot th .h after iostream, and your int main needs to return 0, so here''s your new source coode:
#include <iostream.h>
int main ()
{
int i;
cout << "Type a number: ";
cin >> i;
if ((i%2)!=0) cout << "Number is odd.\n";
else cout << "Number is even.\n";
return 0;
}
See ya.
"Your mother was a hamster and your father smelled of elderberries."
#include <iostream.h>
int main ()
{
int i;
cout << "Type a number: ";
cin >> i;
if ((i%2)!=0) cout << "Number is odd.\n";
else cout << "Number is even.\n";
return 0;
}
See ya.
"Your mother was a hamster and your father smelled of elderberries."
You have forgot to qualify the std namespace in some way.
or
Hope that helps
#include <iostream>
using namespace std;
int main ()
{
int i;
cout << "Type a number: ";
cin >> i;
if ((i%2)!=0) cout << "Number is odd.\n";
else cout << "Number is even.\n";
}
or
#include <iostream>
int main ()
{
int i;
std::cout << "Type a number: ";
std::cin >> i;
if ((i%2)!=0) std::cout << "Number is odd.\n";
else std::cout << "Number is even.\n";
}
Hope that helps
What's the difference between <xxx> and <xxx.h> headers?
to the Original Poster, you'll get far better answers if instead of just posting code and asking "what's wrong with this?" you post a series of the reasons why you think it's wrong and why you don't understand how to fix it.
e.g.
post the error messages the compiler gives you.
Say that you've looked it up and don't understand the terms
or
post the error messages the compiler gives you.
Say that you've looked it up and understand what its saying but don't seem to be able to fix it.
or
Say that it's not giving the results you'd expect. Say what they are and what you expected. Say why they shouldn't be what you're getting
etc.
[edited by - petewood on January 19, 2004 11:28:02 AM]
to the Original Poster, you'll get far better answers if instead of just posting code and asking "what's wrong with this?" you post a series of the reasons why you think it's wrong and why you don't understand how to fix it.
e.g.
post the error messages the compiler gives you.
Say that you've looked it up and don't understand the terms
or
post the error messages the compiler gives you.
Say that you've looked it up and understand what its saying but don't seem to be able to fix it.
or
Say that it's not giving the results you'd expect. Say what they are and what you expected. Say why they shouldn't be what you're getting
etc.
[edited by - petewood on January 19, 2004 11:28:02 AM]
quote:
Original post by Jingoquote:
Original post by petewood
you''ll get far better answers if instead of just posting code and asking "what''s wrong with this?"
Are you saying there is something wrong with my answers?
gosh... sorry about that... that was a real freudian slip.
quote:
Original post by uller
iostream.h and iostream are both correct
in what way is iostream.h correct?
quote:
however iostream.h is a relic only around for backward compatibility
that is true in as much as it is for compatibility with code written before standardisation. The iostream.h library and iostream library are very different. The iostream library works with iterators and the STL.
quote:
like goto statements and the like
goto is part of the standard
[edited by - petewood on January 21, 2004 8:02:37 AM]
Topic Locked
This topic has been locked by a moderator. New replies are not allowed.
Sign in to reply to this topic.
Advertisement