Welcome to HBH! If you have tried to register and didn't get a verification email, please using the following link to resend the verification email.

Need help with my C++ program please


TROY's Avatar
The Krazy Bastard
0 0

First of all i just want to say im really sorry and i apolagize for these posts that i am doing, they are normally very long and probably confusing of which im really sorry, but i would really appreciate some help. Thanks, anyway…..

i've been working on this "Number detailer", which is what i call it since i have no other name for it (lol :P) and im having a few problems with it, it is ment to be a program that instead of making you enter what you want to do with the two numbers, it does everything ( square the numbers, add them, subtract them multiply them, divide them, all at the same time and then gives you the results of all of these things, anyway this is the code:

/* This is a calculator designed, programmed and made by Tr0y, however this calulator is differnt though, you enter two numbers and then it give you the sum product subtraction, square root, etc of your two number, sort of like a number detailer (If they actually even do exist)*/

#include <iostream> using namespace std;

int main() { cout<<"Hello and welcome to the number detailer, designed, programmed and made by Tr0y.\n" "To continue, press Enter to see the menu"<<endl; cin.get(); loop: cout<<"Press a number 1 to 3 for one of the options displayed below.\n"; cout<<"1. View information about the author and the program.\n"; cout<<"2. View the programs C++ code.\n"; cout<<"3. To procede to the Number detailer.\n"; cout<<"Please choose an option now: \n"; int choice; cin>> choice;

if (choice = 1) {
           cout&lt;&lt;&quot;This is a calculator designed, programmed and made by Tr0y, however this&#92;n&quot; &quot;calulator is different though, you enter two numbers and then it give you the &#92;n&quot; &quot;sum,product, subtraction, square root, etc of your two number, It basically&#92;n&quot; &quot;gives you all the details of your two numbers, so if you wanted to know what&#92;n&quot; &quot;5 + 5 was AND 5 * 5, then it would give you these results all at the same time, I call it a number detailer. This program was made by me Tr0y, and i personally give anyone permission to reproduce this program, but NOT,i repeat NOT,&#92;n&quot; &quot;distribute it as your own program, especially if you just copy my code and&#92;n&quot; &quot;change my name to yours, please DON&#39;T do this, Thank you.&#92;n&quot;;       
           cout&lt;&lt;&quot;Press return to go back to the menu&#92;n&quot;;
           cin.get();
           goto loop;
           }
           

else if (choice = 2) { cout<<"\n"; cout<<"Press return to go back to the menu\n";
cin.get(); goto loop;
} else if (choice = 3) { system("cls"); cin.get(); }

           }
           
             

So BASICALLY (TO SUMERISE) when you get to the menu, it give you three choices and i have put differnt things for these choices, so if the person chooses 1 the get the message for number 1, they enter 2 then they get the message for number 2, and finally when they enter three they get the message for choice three…..However the problem is that no matter what number you put (1-3) it gives you the message for choice number one, im not sure where im going wrong to be honest, it must be a problem with my IF syntaxes or something. Any help would be GREAT! thanks.:D


Futility's Avatar
:(
80 122

= is the assignment operator. == is for comparison.


TROY's Avatar
The Krazy Bastard
0 0

Futility wrote: = is the assignment operator. == is for comparison.

Yep!, works great now, Thanks very very much. :D


hellboundhackersok's Avatar
Banned
0 0

TROY wrote: cout<<"Hello and welcome to the number detailer, designed, programmed and made by Tr0y.\n" "To continue, press Enter to see the menu"<<endl;

wait.. shouldn't this be:

markupcout &lt;&lt; &quot;Hello.. blah blah.. made by Tr0y.&#92;n&quot; **&lt;&lt;** &quot;To continue blahblahblah&quot; &lt;&lt; endl; ?? Notice the <<


bl4ckc4t's Avatar
Banned
0 0

moshbat wrote: Seriously, read up on your preferred language.:right:

QFT


K3174N 420's Avatar
Satan > God
0 0

moshbat wrote: [quote]bl4ckc4t wrote: [quote]moshbat wrote: Seriously, read up on your preferred language.:right:

QFT[/quote] "Quality fæces Time"? [/quote]

First thing i thought was 'Quit Fucking Talking', Though i could be completly wong and i'ts 'Quite Fucking True'…

Im pretty sure on the middle word… ^^

Anyway, what a dumb post, the differance between = and == is basic. Fundimental. You do need to reread the basics on your languages…


bl4ckc4t's Avatar
Banned
0 0

K3174N 420 wrote: [quote]moshbat wrote: [quote]bl4ckc4t wrote: [quote]moshbat wrote: Seriously, read up on your preferred language.:right:

QFT[/quote] "Quality fæces Time"? [/quote]

First thing i thought was 'Quit Fucking Talking', Though i could be completly wong and i'ts 'Quite Fucking True'…

Im pretty sure on the middle word… ^^

Anyway, what a dumb post, the differance between = and == is basic. Fundimental. You do need to reread the basics on your languages…[/quote]


ghost's Avatar
0 0

I liked quit fucking talking better.


ghost's Avatar
0 0

Also, when posting code it's just kind of etiquette to use the code tags and disable smileys. Finally, when learning the C/++ programming languages, I highly recommend you start with C. There's a lot of OOP stuff that's going to throw you for a loop, and when you decide to go more advanced you're going to be pulling your hair out because you didn't start with C first. here's a good analogy: You can either climb a very tall rock wall or carve a steep but manageable slope. C is very powerful as well.


ghost's Avatar
0 0

I believe I'll take that advice and run with it. I have been having trouble making up my mind, whether to start with C or jump straight into C++, and even though I understand the OOP paradigm very well, I still think it would be a good idea to start with C. Plus, after you get the syntax down, there are plenty of languages based on the C syntax, so it would be a lot easier to learn other languages after you got C down. Thanks for helping me make up my mind, I don't know why, but when you put it that way it just kind of clicked with me. lol.


ghost's Avatar
0 0

Although, on the same note, I found a pretty good tutorial for C and C++, the main one being on C++, thats what the site really focuses on, and they say that with this tutorial, unless you have a specific reason to only learn C, to go ahead into C++, because they start out with all the basic syntax and functions in C (which are the same in C++), and basically teach you C and then tack the OOP and STL on the end for C++. Maybe that would be too much all at once, I don't know, but its basically C until you get to the end of the tutorial, or e-book I should say. Ahh, I digress. I think I'll start on C, but not stay with it very long and go to C++ after I get the basic syntax/functions down, because I get OOP. Blah.


spyware's Avatar
Banned
0 0

It's not "quite fucking true", QFT stands for "Quoted for truth". Mkay? Mkay.


TROY's Avatar
The Krazy Bastard
0 0

spyware wrote: It's not "quite fucking true", QFT stands for "Quoted for truth". Mkay? Mkay.

lol


yours31f's Avatar
Retired
10 0

Try googleing switch case.


ynori7's Avatar
Future Emperor of Earth
0 0

I dont see why everyone keeps saying to start with C. C++ is much more user friendly for a beginner. Learn the basics with C++ and then move to C.


TROY's Avatar
The Krazy Bastard
0 0

ynori7 wrote: I dont see why everyone keeps saying to start with C. C++ is much more user friendly for a beginner. Learn the basics with C++ and then move to C.

Yeah im sticking with C++, i like it and btw people cans top posting i completed my program successfully earlier today, my first quite long C++ program:D lol.


bl4ckc4t's Avatar
Banned
0 0

spyware wrote: It's not "quite fucking true", QFT stands for "Quoted for truth". Mkay? Mkay.

It has a double meaning, 90% of the time it is used in a quote in which the quoted says something that the quotee agreed with. Quoted for Truth can mean the same thing as Quite Fucking True. Mkay? Mkay.


spyware's Avatar
Banned
0 0

bl4ckc4t wrote: It has a double meaning, 90% of the time it is used in a quote in which the quoted says something that the quotee agreed with. Quoted for Truth can mean the same thing as Quite Fucking True. Mkay? Mkay.

It doesn't have "more" meanings, (well, it does), but it DOESN'T mean "quite fucking true".

The meaning is "quoted for truth". That, and nothing else. Other meanings are assigned when people forget the real/true meaning of the abbreviation. Of course, in this case "quite fucking true" has the same meaning as "quoted for truth", that doesn't make it the valid meaning though.


bl4ckc4t's Avatar
Banned
0 0

Upon further review, The ruling on the play is overturned. Spyware's ball.


ghost's Avatar
0 0

TROY wrote: [quote]ynori7 wrote: I dont see why everyone keeps saying to start with C. C++ is much more user friendly for a beginner. Learn the basics with C++ and then move to C.

Yeah im sticking with C++, i like it and btw people cans top posting i completed my program successfully earlier today, my first quite long C++ program:D lol.[/quote]

Anything under 500 lines = short