Jump to content

View more

Image of the Day

Boxes as reward for our ranking mode. ヾ(☆▽☆)
#indiedev #gamedev #gameart #screenshotsaturday https://t.co/ALF1InmM7K
IOTD | Top Screenshots

The latest, straight to your Inbox.

Subscribe to GameDev.net Direct to receive the latest updates and exclusive content.


Sign up now

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

4: Adsense

Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.


  • You cannot reply to this topic
7 replies to this topic

#1 StoNeD_TrOLL   Members   

122
Like
Likes
Like

Posted 26 January 2002 - 01:37 PM

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

#2 Shannon Barber   Moderators   

1674
Like
Likes
Like

Posted 26 January 2002 - 01:43 PM

std::cin >> sibling;

#3 StoNeD_TrOLL   Members   

122
Like
Likes
Like

Posted 26 January 2002 - 01:44 PM

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

#4 tetsu   Members   

122
Like
Likes
Like

Posted 26 January 2002 - 01:49 PM

it should be
std::cout<<"\nHaHa,that sucks!\n";

#5 StoNeD_TrOLL   Members   

122
Like
Likes
Like

Posted 26 January 2002 - 01:52 PM

I still get those errors!

#6 Null and Void   Members   

1087
Like
Likes
Like

Posted 26 January 2002 - 01:55 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;
}




#7 terminate   Members   

259
Like
Likes
Like

Posted 26 January 2002 - 03:36 PM

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)


#8 StoNeD_TrOLL   Members   

122
Like
Likes
Like

Posted 27 January 2002 - 03:48 PM

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.






Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.