• Advertisement

Archived

This topic is now archived and is closed to further replies.

if and else error<<<---------------------needs help!!

This topic is 5835 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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; }

Share this post


Link to post
Share on other sites
Advertisement
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

Share this post


Link to post
Share on other sites
  
#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;
}


Share this post


Link to post
Share on other sites
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)

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites

  • Advertisement