I am working on my homework code. I am having difficulty organizing. I just need the right functions(calling them is easy).
And I don't know how to print out a table that is asked for(we go way fast in this class, I don't know why).
here is the link for all that I have to do, it isn' t so much because they tell you what to do.
http://www.engineering.uiowa.edu/~ci...ll02/hw02.html
here is my code anyways. the last function is supposed to print out a table, max of 50 stars(b/c voltage max);
I talked to my TA about it, but they sometimes don't make any sense. they communicate different, sometimes they do though.Code:lude <stdio.h> float read_positive(void); float calc_tau(float r, float c); float calc_v_of_t(float v, float tua, float t); void print_bar(float value, float max); int main() { float voltage, resistance, capacitance; printf( "please put in the voltage source voltage, units of volts" ); scanf( "%f", &voltage ); printf( "please put in the resistor resistance, in ohms units" ); scanf( "%f", &resistance ); printf( "please put in the capacitance" ); scanf( "%f", %capacitance ); return 0; } float read_positive(void) { printf( "Please put in a real number" ); scanf( "%d", &r ); return r; } float calc_tau(float r, float c) { float r, c, tau; printf( "please put in your resistor resistance in units of kiloohms for an accurate answer" ); scanf( "%f", &r ); printf( "please put in your capacitance in units of micofarads for an accurate answer" ); scanf( "%f", &c ); tau = r * c; return tau; } float calc_v_of_t(float v, float tua, float t) { printf( "and please put in the time for the circuit to run as a closed circuit, units of seconds" ); scanf( "%f", t); v = v - v*(e^(-t/tau); return v; } void print_bar(float value, float max) { }
void print_bar(float value, float max) is supposed to print that table like:
Time Voltage
-------------------------
0.00000 0.00000
1.00000 3.83796 *******
2.00000 7.08672 **************
3.00000 9.83673 *******************
4.00000 12.16457 ************************
5.00000 14.13504 ****************************
6.00000 15.80301 *******************************
(and so on



LinkBack URL
About LinkBacks


