View unanswered posts | View active topics It is currently Fri Dec 27, 2024 7:44 am



Reply to topic  [ 38 posts ]  Go to page 1, 2, 3  Next
 C++ 
Author Message
User avatar

Joined: Fri Dec 15, 2006 5:28 am
Posts: 978
Location: Texas
Reply with quote
Post 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
Profile

Joined: Mon Dec 04, 2006 3:34 am
Posts: 2378
Reply with quote
Post Re: C++
Why are they all ints/not declared to a value etc.


Mon Oct 01, 2007 4:40 am
Profile
User avatar

Joined: Sat Jun 16, 2007 2:31 am
Posts: 2982
Location: Texas
Reply with quote
Post 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
Profile
User avatar

Joined: Fri Dec 15, 2006 5:28 am
Posts: 978
Location: Texas
Reply with quote
Post Re: C++
Because that causes more errors and requires I declare more stuff.


Mon Oct 01, 2007 4:44 am
Profile
User avatar

Joined: Fri Dec 15, 2006 5:28 am
Posts: 978
Location: Texas
Reply with quote
Post 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
Profile
User avatar

Joined: Sat Jun 16, 2007 2:31 am
Posts: 2982
Location: Texas
Reply with quote
Post Re: C++
once again. what is the name of the class?


Mon Oct 01, 2007 4:47 am
Profile

Joined: Mon Dec 04, 2006 3:34 am
Posts: 2378
Reply with quote
Post 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
Profile
User avatar

Joined: Fri Dec 15, 2006 5:28 am
Posts: 978
Location: Texas
Reply with quote
Post Re: C++
whitty wrote:
once again. what is the name of the class?



Class? What now?


Mon Oct 01, 2007 4:48 am
Profile
User avatar

Joined: Sat Jun 16, 2007 2:31 am
Posts: 2982
Location: Texas
Reply with quote
Post Re: C++
whats the name of your computer science class?
like object oriented programming, program scripting, what?


Mon Oct 01, 2007 4:50 am
Profile

Joined: Mon Dec 04, 2006 3:34 am
Posts: 2378
Reply with quote
Post Re: C++
What does that have to do with anything...


Mon Oct 01, 2007 4:50 am
Profile
User avatar

Joined: Fri Dec 15, 2006 5:28 am
Posts: 978
Location: Texas
Reply with quote
Post 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
Profile

Joined: Mon Dec 04, 2006 3:34 am
Posts: 2378
Reply with quote
Post 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
Profile
User avatar

Joined: Sat Jun 16, 2007 2:31 am
Posts: 2982
Location: Texas
Reply with quote
Post 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
Profile

Joined: Mon Dec 04, 2006 3:34 am
Posts: 2378
Reply with quote
Post Re: C++
CC is done in C++, .inis are just variable lists.


Mon Oct 01, 2007 4:56 am
Profile
User avatar

Joined: Fri Dec 15, 2006 5:28 am
Posts: 978
Location: Texas
Reply with quote
Post Re: C++
Alenth; this is with your code. Mine does the exact same thing.


Attachments:
File comment: The err.
Untitled.png
Untitled.png [ 32.1 KiB | Viewed 4402 times ]
Mon Oct 01, 2007 4:59 am
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 38 posts ]  Go to page 1, 2, 3  Next

Who is online

Users browsing this forum: No registered users


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by STSoftware for PTF.
[ Time : 0.071s | 15 Queries | GZIP : Off ]