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

Started by
6 comments, last by StoNeD_TrOLL 22 years, 2 months ago
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; }
Advertisement
std::cin >> sibling;
- The trade-off between price and quality does not exist in Japan. Rather, the idea that high quality brings on cost reduction is widely accepted.-- Tajima & Matsubara
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
it should be
std::cout<<"\nHaHa,that sucks!\n";
--Samuel AnderssonOmnigames.se
I still get those errors!
  #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)
Those who dance are considered insane by those who cannot hear the music.
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