![]() |
|
#1
|
|||
|
|||
How do I add arrays into my program?Trying to make this setup for my arrays:
Print Output Format: Print total resistance followed by the values of each resistor. For series: (Example) Total series resistance is 2.123 kOhm for 3 resistors: 1000 kOhm, 1000 kOhm, 123 kOhm For parallel: (Example) Total series resistance is 500 Ohm for 2 resistors: 1000 Ohm, 1000 Ohm Its not compiling need help!...i think my parallel code is incorrect along with my arrays. CPP / C++ / C Code:
Last edited by admin : 29-Oct-2009 at 03:44.
Reason: Please insert your example C/C++ codes between [CPP] and [/CPP] tags
|
|||
|
#2
|
|||
|
|||
Re: How do I add arrays into my program?!?!Quote:
CPP / C++ / C Code:
If you are having compilation errors, post the error message and the line of code that it is referencing and we can help. |
|
#3
|
|||
|
|||
Re: How do I add arrays into my program?!?!thanks! i accidentally put that statement under the int.....fixed that.
also these are the errors that are showing up in my code: Line (65) : error C2109: subscript requires array or pointer type Line (71) : warning C4244: '=' : conversion from 'double' to 'int', possible loss of data Line (92) : fatal error C1075: end of file found before the left brace '{' at '.\Resistor Calculation Using Arrays.cpp(9)' was matched |
|
#4
|
|||
|
|||
Re: How do I add arrays into my program?!?!fixed it my errors, compiles but doesn't run the way i want it to.
k...here is what im trying to do..never really gave a proper description of my program Trying to write a program to calculate the resistance connected either in series or parallel. Using arrays in solving the problem/ Prompt the user to select series or parallel. Prompt the user to enter the number of resistors connected. Read/get the value of each of the resistors calculate the resistance. Output the resistance according to the following: Print Output Format: Print total resistance followed by the values of each resistor. For series: (Example) Total series resistance is 2.123 kOhm for 3 resistors: 1000 kOhm, 1000 kOhm, 123 kOhm For parallel: (Example) Total series resistance is 500 Ohm for 2 resistors: 1000 Ohm, 1000 Ohm Avoid division by 0 CPP / C++ / C Code:
Last edited by admin : 29-Oct-2009 at 03:46.
Reason: Please insert your example C/C++ codes between [CPP] and [/CPP] tags
|
|
#5
|
|||
|
|||
Re: How do I add arrays into my program?!?!Reposted your code using CPP tags:
CPP / C++ / C Code:
|
|
#6
|
|||
|
|||
Re: How do I add arrays into my program?!?!One problem that I see immediately is that you have a never-ending loop where you ask for input and put it into arrays.
Try creating the program to run without a loop first so that each time you run the program, it runs through the process of collecting user input and displaying output just once. In other words, take out the while(true) loop and see what happens. |
|
#7
|
|||
|
|||
Re: How do I add arrays into my program?!?!yes that was the issue! the while (true)
now trying to get the format output correct: "Print Output Format: Print total resistance followed by the values of each resistor." For series: (Example) Total series resistance is 2.123 kOhm for 3 resistors: 1000 kOhm, 1000 kOhm, 123 kOhm For parallel: (Example) Total series resistance is 500 Ohm for 2 resistors: 1000 Ohm, 1000 Ohm this is what shows up now: ![]() |
|
#8
|
|||
|
|||
Re: How do I add arrays into my program?!?!can anyone assist me with this? please? on why the resistor values aren't printing like I stated above and what i have to do to modify my code to print output this way??
|
|
#9
|
|||
|
|||
Re: How do I add arrays into my program?!?!They aren't printing because you have indented with tabs in your code instead of spaces.
After fixing that , if it still does not run as expected post your latest code so we can see EXACTLY what you have at this point. And please enclose the code in the handy cpp tags this time. And while your waiting for a reply , enjoy reading the guidlines... Thank you. Last edited by Howard_L : 28-Oct-2009 at 21:40.
|
|
#10
|
|||
|
|||
Re: How do I add arrays into my program?!?!here is my latest code:
CPP / C++ / C Code:
|
Recent GIDBlog
Problems with the Navy (Chiefs) by crystalattice
| Thread Tools | Search this Thread |
| Rate This Thread | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Equation solver | RazoR | C Programming Language | 3 | 18-May-2008 10:24 |
| Need Help with input files. | Efferus | C++ Forum | 2 | 24-Nov-2007 17:19 |
| Two-Tier data dissemination code installation problem | nidhibansal1984 | Computer Software Forum - Linux | 6 | 16-Sep-2007 11:13 |
| program without arrays | dezstylz | C++ Forum | 3 | 31-May-2006 09:24 |
Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The