if and else error<<<---------------------needs help!!
I dunno whats wrong with my code.Can anybody help?Thanks.
#include <iostream>
int main()
{
int sibling;
std::cout<<"Do you have any siblings?\n";
std::cout<<"10 for yes and 0 for no please\n";
std::cin << sibling;
if (sibling == 10)
std::cout<<"\nLucky!\n";
else (sibling == 0)
std::cout<<\n"HaHa,that sucks!\n";
return 0;
}
Im pretty stupid.
but after changing that i get these errors:
Warning : possible unwanted compare
wab.cpp line 13 std::cout<<\n"HaHa,that sucks!\n";
Error : ';' expected
wab.cpp line 13 std::cout<<\n"HaHa,that sucks!\n";
Edited by - StoNeD_TrOLL on January 26, 2002 8:46:40 PM
but after changing that i get these errors:
Warning : possible unwanted compare
wab.cpp line 13 std::cout<<\n"HaHa,that sucks!\n";
Error : ';' expected
wab.cpp line 13 std::cout<<\n"HaHa,that sucks!\n";
Edited by - StoNeD_TrOLL on January 26, 2002 8:46:40 PM
#include <iostream>int main(void) { int sibling; std::cout << "Do you have any siblings?\n"; std::cout << "10 for yes and 0 for no please\n"; std::cin >> sibling; if(sibling == 10) std::cout << "\nLucky!\n"; else if(sibling == 0) std::cout<< "\nHaHa,that sucks!\n"; return 0;}
first
add
using namespace std;
to the top of your program (after the includes, before main()), then you can get rid of the std:: on cput and cin
else(sibling == 0)
should be
else if(sibling == 0)
add
using namespace std;
to the top of your program (after the includes, before main()), then you can get rid of the std:: on cput and cin
else(sibling == 0)
should be
else if(sibling == 0)
quote:Original post by Null and Void
#include <iostream>int main(void) { int sibling; std::cout << "Do you have any siblings?\n"; std::cout << "10 for yes and 0 for no please\n"; std::cin >> sibling; if(sibling == 10) std::cout << "\nLucky!\n"; else if(sibling == 0) std::cout<< "\nHaHa,that sucks!\n"; return 0;}
That helps!Thanks.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement