working on a program that works out complex curtits and im stuck im am useing pella c to wright the program. the weird thing is that it run fine to put in the voltage the how many resisters then crashes.here it is.

Code:
```#include <stdio.h>

void instructions (void); //print intructions
void draw_v (double v); //function for voltage line
void initial(double r1);
//calc functions
double totr (struct resist add, int n, double r1);
double toti (double r, double v);
double power (double i, double v);
void display (double r, double i, double p);//display funtion

int
main (void)
{
int n; //number of resistors

char decide; //check printed curcuit
double v; //voltage
double r1; //initial resistor

instructions ();

printf ("What is your source voltage?    \n");
scanf ("%lf.3", &v);
while (v <1){
printf ("Try again...    \n");
scanf ("%lf.3", &v);
}

printf ("How many resistors are in your circuit?     \n");
scanf ("%d", &n);
while (n < 1) {
printf ("Entry invalid, please try again...   \n");
scanf ("%d", &n);
}

printf ("What is the value of the initial resistor?  \n");
scanf ("%lf", &r1);
while ( r1 < 0) {
printf ("What is the value of the initial resistor, now?  \n");
scanf ("%lf", &r1);
}
double more[n-1]; //array variable in struct
char and [n-1]; //array variable in struct
int i; //initiator variable

do {
printf ("What is the value of your next resistor?    \n");
scanf("%lf", more[i]);
printf ("And what is this resistor's relationship to the previous resistor?    %.3f\n");
scanf ("%c", and[i]);
while  (i = n -1, i < n && i > 0, i -- );
draw_v (v);
initial (r1);
printf ("\n Is this the circuit you would like solved?    %c \n", decide);
scanf ("%c", &decide);
while (decide != 'y' || 'n'){
printf ("Please answer y for yes or n for no...   %c  \n", decide);
scanf ("%c", &decide);
}
if (decide == 'n')
else

//values not passed from main
toti;
power;
display;

return (0); //main/////////////////////////////////////////////////////////////////////
}
//////////////////////////////////////////////////////////////////////////////////////
void instructions (void)
{
printf ("This program will only work if you can make one continuous line through your circuit. \n");
printf ("This program will only work if your circuit has only one voltage source. \n");
printf ("This program requires lower case letters for verifiers. \n");
printf ("Enter the value of source voltage. \n");
printf ("Name the number of resistors. Then, starting with the outer most resistor, give the values of each resistor. \n");
printf ("For every additional resistor also give it's relation, series - (s) or parallel - (p), to the previous resistor. \n");
printf ("Next the program will print a simplyfied image of the circuit based on the resistor values that were entered. \n");
printf ("If the circuit is not to your liking type 'n' and start over. \n");
printf ("If the circuit meets your approval type 'y' to recieve your calculations. \n");
printf ("The program will calculate your total resistance, total current,  and total power.\n");
}
//////////////////////////////////////////////////////////////////////////////////////

void draw_v ( double v)
{
printf  ("*");
printf  ("*");
printf  ("*");
printf  ("*");
printf("%lf ",&v);
printf  ("*");
printf  ("*");
printf  ("*");
printf  ("*");
}
////////////////////////////////////////////////////////////////////////////
void draw_lines(struct resist add, int n)
{

printf("**************************");
printf("*                                              ");
printf("*                                              ");
printf("*                                              ");
printf("*                                              ");
printf("*                                              ");
printf("*                                              ");
printf("*                                              ");

}
void initial(double r1)

{
printf  ("*");
printf  ("*");
printf  ("*");
printf  ("*");
printf("%lf", &r1);
printf  ("*");
printf  ("*");
printf  ("*");
printf  ("*");
}

double totr (struct resist add, int n, double r1)
{
double r;
int x;

else

while (x = n-2, x > 0, --x);
}
else {
while (x = n-2, x > 0, --x);
}
return (r);
}

double toti (double v,double r)
{
double i;
i = v/r;
return (i);
}
double power (double i,double v)
{
double p;
p = i*v;
return (p);
}

void display (double r,double i,double p)

{
printf("The total resistance is .3%lf ohms", r);
printf("The total current is .3%lf amperes", i);
printf("The total power is .3%lf watts", p);
}```

2. ## and no this is not for school

i just wanted a way to look at a circuit and not have to do the math every time.

3. Look at your compiler warnings, there should be tons of them. Fix all of those warnings to ensure (slightly) more reliable code. But in particular to your crash, its probably because of these lines
Code:
```	scanf("%lf", more[i]);
printf ("And what is this resistor's relationship to the previous resistor?    %.3f\n");
scanf ("%c", and[i]);```
Where the "scanf" requires an address, like "&myVariable" not "myVariable". If you read the compiler warnings you'd see this warning, though.

4. just a few hints:
Code:
`double more[n-1]; //array variable in struct`
doesn't work, because at compile time n doesn't contain a valid value, better use
Code:
`double more[10]; //array variable in struct`
Code:
`scanf("%lf", more[i]);`
should be
Code:
`scanf("%lf", &more[i]);`
Code:
`	scanf ("%c", and[i]);`
should be
Code:
`	scanf (" %c", &and[i]);`
... mind the blank before %c...
Code:
`	while ((decide != 'y') &&(decide != 'n')){`
does work
ur while loops are complicated, better keep it simple like
Code:
`	 while  (--i >0 );`
(first loop )

develop ur code step by step, verifying the results after each step by using debug/printf statements.
its not useful to write the whole program and then start debugging , because u copy ur mistakes a lot of times and then nothing works as it should do

5. Originally Posted by kermitaner
just a few hints:
Code:
`double more[n-1]; //array variable in struct`
doesn't work, because at compile time n doesn't contain a valid value
I sometimes forget this, too, but variable length arrays were added in the C99 standard, which we can assume he/she is using, otherwise it wouldn't compile (so he/she wouldn't know of a runtime error).

6. ## no warnings

the compiler build it with on erros or warnings

7. I actually can't continue to believe anything you say, considering the lack of proper grammar and coherency. Just because its not giving any warnings right now is probably because the warning level isn't strict enough. To make it more strict, look at the documentation for whatever compiler (or IDE and compiler) you're using.