Hi all!

I need help for the following code. When I try to compile it, the program blocks the line printf (" kA(T2-T1) \n") .

I don't understand what's wrong with that line.

Also, I don't know whether I use variable "counter" the right way. The idea is to count the input from the user. If it's not 5, that means one must be 0 (the one with the question mark inputted), and thus will go to the respective function. But if it's 5, the user must input again the data. At this point I don't understand how to loop it back to the first 6 steps (inquiring input from user).

Anyone,,please help me with this.

Thank you so much before. ^^

Code:`/* This program is used to solve simple conduction problems using various forms of the formula*/`

#include <stdio.h> /* define printf and scanf */

#include <math.h> /* define mathematical operations */

double calc_h (double coef, double thickness, double area, double temp1, double temp2) ; /* define function named calc_k */

double calc_k (double heat_rate, double thickness, double area, double temp1, double temp2) ; /* define function named calc_k */

double calc_a (double heat_rate, double thickness, double coef, double temp1, double temp2) ; /* define function named calc_a */

double calc_x (double heat_rate, double coef, double area, double temp1, double temp2) ; /* define function named calc_x */

double calc_t2 (double heat_rate, double thickness, double area, double temp1, double coef) ; /* define function named calc_t1 */

double calc_t1 (double heat_rate, double thickness, double area, double coef, double temp2) ; /* define function named calc_t2 */

main()

{

/* define variables that will be used */

double heat_rate ;

double coef ;

double area ;

double temp1 ;

double temp2 ;

double thickness ;

int counter ;

/* mention the background and the purpose of the program */

printf ("Respond to the the prompts with the data known, \n") ;

printf ("Unknown quantity, enter a question mark (?). \n") ;

printf ("Rate of heat transfer (unit = watts) ---> \n") ;

scanf ("%lf",&heat_rate) ;

printf ("Coefficient of thermal conductivity (unit = W/m-K) ---> \n") ;

scanf ("%lf",&coef) ;

printf ("Cross sectional area of conductor (unit = m^2) ---> \n") ;

scanf ("%lf",&area) ;

printf ("Temperature on the first side (unit = Kelvin) ---> \n") ;

scanf ("%lf",&temp1) ;

printf ("Temperature on the second side (unit = Kelvin) ---> \n") ;

scanf ("%lf",&temp2) ;

printf ("Thickness of conductor (unit = m) ---> \n") ;

scanf ("%lf",&thickness) ;

counter = scanf ("%lf %lf %lf %lf %lf %lf", &heat_rate, &coef, &area, &temp1, &temp2, &thickness) ;

if (counter == 0)

{

if(heat_rate == 0)

{

calc_h (coef, thickness, area, temp1, temp2) ;

}

else if (coef == 0)

{

calc_k (heat_rate, thickness, area, temp1, temp2) ;

}

else if (area == 0)

{

calc_a (heat_rate, thickness, coef, temp1, temp2) ;

}

else if (temp1 == 0)

{

calc_t1 (heat_rate, thickness, area, coef, temp2) ;

}

else if (temp2 == 0)

{

calc_t2 (heat_rate, thickness, area, temp1, coef) ;

}

else

{

calc_x (heat_rate, coef, area, temp1, temp2) ;

}

}else

{

printf ("Invalid input! You must input a question mark for the unknown variable. \n") ;

}

}

printf (" kA (T2-T1) \n") ;

printf (" H = ------------ \n") ;

printf (" x \n") ;

printf ("H = %lf W T2 = %lf K" ,heat_rate, temp2) ;

printf ("k = %lf W/m-K T1 = %lf K", coef, temp1) ;

printf ("A = %lf m^2 x = %lf m" , area, thickness) ;

system ("PAUSE") ;

return 0 ;

}

/* function named calc_k, used to calculate the coefficient of thermal conductivity */

double calc_k (double heat_rate, double thickness, double area, double temp1, double temp2)

{

return ((heat_rate*thickness)/(area*(temp2-temp1))) ;

}

/* function named calc_a, used to calculate the cross sectional area */

double calc_a (double heat_rate, double thickness, double coef, double temp1, double temp2)

{

return ((heat_rate*thickness)/(coef*(temp2-temp1))) ;

}

/* function named calc_x, used to calculate the thickness of the conductor */

double calc_x (double heat_rate, double coef, double area, double temp1, double temp2)

{

return ((coef*area*(temp2-temp1))/heat_rate) ;

}

/* function named calc_h, used to calculate the rate of heat transfer */

double calc_h (double coef, double thickness, double area, double temp1, double temp2)

{

return ((coef*area*(temp2-temp1))/thickness) ;

}

/* function named calc_t2, used to calculate the temperature on the second or furthest side of the conductor */

double calc_t2 (double heat_rate, double thickness, double area, double temp1, double coef)

{

return (((heat_rate*thickness)/(coef*area))+temp1) ;

}

/* function named calc_t1, used to calculate the temperature on the first or nearest side of the conductor */

double calc_t1 (double heat_rate, double thickness, double area, double coef, double temp2)

{

return (temp2-((heat_rate*thickness)/(coef*area))) ;

}