![]() |
|
#1
|
|||
|
|||
Program output wrongOk guys I'm back. this time im a little farther in the chapter though
this time i'm trying to get 3 intergers from a user then calculate and print the sum, average, product, smallest and largest of the numbers. the program runs fine the only problem is that it prints out the smallest two numbers instead of just the smallest one. here is the code CPP / C++ / C Code:
ive run this through my head and on the pc using the numbers 3,4,5 but it still gives me this output enter three intergers 3 4 5 sum is 12 average is 4 product is 60 largest is 5 smallest is 3 smallest is 4 thanks again for any help guys. Last edited by admin II : 25-Mar-2008 at 04:10.
Reason: Please surround your C++ code with [cpp] your code [/cpp]
|
|||
|
#2
|
|||
|
|||
Re: Program output wrongQuote:
Consider the statement CPP / C++ / C Code:
Here's what happens (expressions separated by commas are evaluated one at a time from left to right): 1. The expression x>y is evaluated (but nothing is done with the result). 2. The expression x>z is evaluated. If the result it "true," then the following statement is executed, otherwise it is not. Similarly for your other logical expressions. Maybe you mean: CPP / C++ / C Code:
Etc. Regards, Dave |
|
#3
|
|||
|
|||
Re: Program output wrongThank you very much. I have not gotten that far in the book yet. I thought that the statement separated by the comma meant &. OK, back to the book. Thanks again.
|
Recent GIDBlog
Updates On The All New Toyota VIOS - Part III by Nihal
| Thread Tools | Search this Thread |
| Rate This Thread | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Need Intermediate output of one program into another... | madhu542 | C Programming Language | 1 | 27-Nov-2007 03:02 |
| Two-Tier data dissemination code installation problem | nidhibansal1984 | Computer Software Forum - Linux | 6 | 16-Sep-2007 10:13 |
| Cut -> C | bulbulred | C Programming Language | 3 | 28-May-2006 15:07 |
| Program output in wrong order | strangr314 | CPP / C++ Forum | 3 | 08-Jul-2005 12:42 |
Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The