Author |
Message |
Kelas
Joined: Fri Dec 15, 2006 5:28 am Posts: 978 Location: Texas
|
C++
Right, I am in a computer science class, and in said class, we are learning C++. And I need some help. Code: #include <iostream>
int main() { std::cout<<"Yes or no?\n"; int choice; int yes; int no; std::cin>>choice; if (choice==yes){std::cout<<"Hello";} if (choice==no) {std::cout<<"Bye";} else {std::cout<<"PICK YES OR NO ladylike";} return 0; }
It keeps on displaying the std::cout of the selected choice, AND the last if statement. (Note, I know there's and else command, it still did the same thing)(Ninja edit; I made it say else) Also, to make this thread a bit more worthwhile, this will become the collaberative C++ "mini-community" thread thingy. Help eachother with C++, teach eachother, etc.
|
Mon Oct 01, 2007 4:28 am |
|
|
Alenth Eneil
Joined: Mon Dec 04, 2006 3:34 am Posts: 2378
|
Re: C++
Why are they all ints/not declared to a value etc.
|
Mon Oct 01, 2007 4:40 am |
|
|
whitty
Joined: Sat Jun 16, 2007 2:31 am Posts: 2982 Location: Texas
|
Re: C++
whats the name of the class?
and i think int means... wait no it doesn't.
|
Mon Oct 01, 2007 4:44 am |
|
|
Kelas
Joined: Fri Dec 15, 2006 5:28 am Posts: 978 Location: Texas
|
Re: C++
Because that causes more errors and requires I declare more stuff.
|
Mon Oct 01, 2007 4:44 am |
|
|
Kelas
Joined: Fri Dec 15, 2006 5:28 am Posts: 978 Location: Texas
|
Re: C++
int means integer. I know. String doesn't work. At least we haven't learned it in class because it requires importing another library or some ♥♥♥♥ like that.
|
Mon Oct 01, 2007 4:45 am |
|
|
whitty
Joined: Sat Jun 16, 2007 2:31 am Posts: 2982 Location: Texas
|
Re: C++
once again. what is the name of the class?
|
Mon Oct 01, 2007 4:47 am |
|
|
Alenth Eneil
Joined: Mon Dec 04, 2006 3:34 am Posts: 2378
|
Re: C++
Strings are shitty.
Anyways, you have nothing to ♥♥♥♥ compare to with that code, it will always say that you put in the wrong thing.
|
Mon Oct 01, 2007 4:47 am |
|
|
Kelas
Joined: Fri Dec 15, 2006 5:28 am Posts: 978 Location: Texas
|
Re: C++
whitty wrote: once again. what is the name of the class? Class? What now?
|
Mon Oct 01, 2007 4:48 am |
|
|
whitty
Joined: Sat Jun 16, 2007 2:31 am Posts: 2982 Location: Texas
|
Re: C++
whats the name of your computer science class? like object oriented programming, program scripting, what?
|
Mon Oct 01, 2007 4:50 am |
|
|
Alenth Eneil
Joined: Mon Dec 04, 2006 3:34 am Posts: 2378
|
Re: C++
What does that have to do with anything...
|
Mon Oct 01, 2007 4:50 am |
|
|
Kelas
Joined: Fri Dec 15, 2006 5:28 am Posts: 978 Location: Texas
|
Re: C++
Kelas wrote: Right, I am in a computer science class, and in said class, we are learning C++. Name=Computer Science.
|
Mon Oct 01, 2007 4:51 am |
|
|
Alenth Eneil
Joined: Mon Dec 04, 2006 3:34 am Posts: 2378
|
Re: C++
Still Code: #include <iostream>
int main() { std::cout<<"Yes or no? (1||0)\n"; int choice; int yes = 1; int no = 0; std::cin>>choice; if (choice==yes){std::cout<<"Hello";} if (choice==no) {std::cout<<"Bye";} else {std::cout<<"PICK 1 OR 0 ladylike";} return 0; }
Then I realise I don't remember variables being set like that(cin), but C++ was a long time ago. Whatever.
|
Mon Oct 01, 2007 4:53 am |
|
|
whitty
Joined: Sat Jun 16, 2007 2:31 am Posts: 2982 Location: Texas
|
Re: C++
k thanks.
@alenth: i wanted to know so i can take that class next year XD
we have a comp. science class at my skewl yay
kelas: tell people you'll teach them cortex command coding if they help you with that c++
wait but doesnt CC use c++ ?
|
Mon Oct 01, 2007 4:54 am |
|
|
Alenth Eneil
Joined: Mon Dec 04, 2006 3:34 am Posts: 2378
|
Re: C++
CC is done in C++, .inis are just variable lists.
|
Mon Oct 01, 2007 4:56 am |
|
|
Kelas
Joined: Fri Dec 15, 2006 5:28 am Posts: 978 Location: Texas
|
Re: C++
Alenth; this is with your code. Mine does the exact same thing.
Attachments:
File comment: The err.
Untitled.png [ 32.1 KiB | Viewed 4402 times ]
|
Mon Oct 01, 2007 4:59 am |
|
|
|