![]() |
|
#1
|
|||
|
|||
Something wrong...I'm a beginner and I created a code to figure out the volume or area of a rectangular prism. It's supposed to ask you if you want area or volume, then ask you for its dimensions and give you what you told it to give you (area or volume)
However, mine gives both the area and the volume, no matter what I put at the beginning. Here's the code: CPP / C++ / C Code:
What's wrong? I think it's something to do with if (whatYouWant == "volume") |
|||
|
#2
|
||||
|
||||
Re: Something wrong...You have a couple of semicolons that shouldn't be there.
Here: CPP / C++ / C Code:
and here CPP / C++ / C Code:
When you put those semicolons at the ends of those lines, that marks the end of the conditionals, and the code below in the curly braces is always executed. Take them out, and it works: CPP / C++ / C Code:
__________________
www.blake-foster.com |
|
#3
|
|||
|
|||
Re: Something wrong...Thanks for the help, it works now
|
|
#4
|
|||
|
|||
Re: Something wrong...I've got another problem now. I want it to say
Please type "v" or "a". if the person doesn't type in v or a at the beginning, but it always says it, no matter what I type... It should go on to asking the dimensions of the cube if you type v or a but it doesn't. It's something to do with the != and || You only need the start of the code: CPP / C++ / C Code:
|
|
#5
|
||||
|
||||
Re: Something wrong...That OR should be an AND.
CPP / C++ / C Code:
__________________
www.blake-foster.com |
|
#6
|
|||
|
|||
Re: Something wrong...Thanks a lot Blake!
|
Recent GIDBlog
Programming ebook direct download available by crystalattice
| Thread Tools | Search this Thread |
| Rate This Thread | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Trying to read BMP files, header information is wrong / offset | Algar | C++ Forum | 5 | 24-Feb-2008 04:00 |
| String trim problem and wrong node routing agent! | newbie06 | Computer Software Forum - Linux | 8 | 02-Mar-2007 00:51 |
| Problem with if statement (was: what is wrong???) | rubenryhan | C Programming Language | 2 | 02-May-2005 09:09 |
| Functions and Classes - Where did I go wrong? | redmage | C++ Forum | 5 | 10-Apr-2005 19:31 |
| something wrong with this code | loon | MySQL / PHP Forum | 5 | 07-Jul-2003 06:55 |
Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The