Would someone please run my program to see what I'm doing wrong? My program is at the bottom of the page.


Refrigerator cycle: cop = Tc / Th - Tc



Heat pump: cop = Th / Th - Tc

where Tc and Th are the absolute temperatures (K) of cold and hot reservoirs.



Implementation Details:

Write a function to enter and return the temperatures of the cold and hot reservoirs in degrees Celsius; return them through pointer parameters. Make sure that both are greater than absolute 0(allow the user to correct any errors) and that they have the proper relationship to one another; that is Th > Tc (if not, swap them).
Write a function to convert a Celsius temperature to an absolute temperature in degrees Kelvin. Absolute 0 is -273.15 degrees Celsius.
Write a function, name cop(), that will compute both values of cop, given the Th and Tc, and return the results using call by address.
Write a main program that will calculate and print the values of cop for either a refrigerator or a heat pump. Use a query loop to repeat the process, asking the user to select one or the other computation or "quit". Do the input and calculations using functions described above. Although the cop() function returns two results, print only the result that the user requested.


Hint:

Kelvin = Celsius + 273.15;





Select your computation, 1 for heat pump or 2 for refrigerator :1

Enter temperatures for hot and cold reservoirs.

Temperatures must be greater than -273.15 and

hot reservoir temperature must be greater

than cold reservoir temperature.

56 78

Temp = 56.00 (cold) and 78.00 (hot) in Celsius

Temp = 329.15 (cold) and 351.15 (hot) in Kelvin

The value of cop for heat pump = 15.96

Continue ?? < type 1 to continue. 1



Select your computation, 1 for heat pump or 2 for refrigerator :1

Enter temperatures for hot and cold reservoirs.

Temperatures must be greater than -273.15 and

hot reservoir temperature must be greater

than cold reservoir temperature.

56 90

Temp = 56.00 (cold) and 90.00 (hot) in Celsius

Temp = 329.15 (cold) and 363.15 (hot) in Kelvin

The value of cop for heat pump = 10.68



Continue ?? < type 1 to continue. 1





Code:
#include <stdio.h>
void enter_temp(float*, float*);
void convert(float*, float*);
void cop(float*, float*,float*, float*);

int main(void){

float h, c, hcop, ccop;
int again=1;
int selection;
float kelvin;
printf("Select your computation, 1 for heat pump or 2 for refrigerator:");
scanf("%d", &selection);

while (again==1){
printf("Continue?? <type 1 to continue>.");
scanf("%d", &again);
}
while(selection !=1 &&  selection !=2){
printf("Select your computation, 1 for heat pump or 2 for refrigerator:");
scanf("%d", &selection);}


enter_temp(&h, &c);
printf("Enter the temperatures for hot and cold reservoirs.\n");
printf("%f%f", &h, &c);
printf("Temperatures must be greater than -273.15 and hot reservoir");
printf("temperatures must be greater than cold reservoir temperature.");

convert(&h, &c);
printf("Temp = %f, &c (cold) and %f, &h (hot) in Celsius\n");

printf("Temp = %f, (cold) and %f (hot) in Kelvin\n", c+273.15, h+273.15);
 scanf("%.2f%.2f", &kelvin);

cop(&h, &c, &hcop, &ccop);

printf ("The value of cop for refrigerator cycle = %f\n", ccop);
scanf("%.2f", &ccop);
printf("The value of cop for heat pump = %f\n", hcop);
scanf("%.2f", &hcop);

printf("Continue?? <type 1 to continue.");
scanf("%d", &again);

return 0;
}
void enter_temp(float *hPtr, float *cPtr){
float h, c;

printf("Enter the temperatures for hot and cold reservoirs.\n");
printf("%f%f", &h, &c);
printf("Temperatures must be greater than -273.15 and hot reservoir");
printf("temperatures must be greater than cold reservoir temperature.");

while (h > -273.15 && c > -273.15){
printf("Enter the temperatures for hot and cold reservoirs.\n");
printf("%f%f", &h, &c);
printf("Temperatures must be greater than -273.15 and hot reservoir");
printf("temperatures must be greater than cold reservoir temperature.");
}
while (h>c){
printf("Enter the temperatures for hot and cold reservoirs.");
printf("%f%f", &h, &c);
printf("Temperatures must be greater than -273.15 and hot reservoir");
printf("temperatures must be greater than cold reservoir temperature.");}


return;

}

void convert(float *hptr, float *cptr){

float h, c, kelvin;

kelvin = h + 273.15;
kelvin = c + 273.15;
printf("Temp = %f, &c (cold) and %f, &h (hot) in Celsius\n");

printf("Temp = %f, (cold) and %f (hot) in Kelvin\n", c+273.15, h+273.15);
 scanf("%.2f%.2f", &kelvin);

return;
}

void cop(float *hPtr,float *cPtr,float *hcopPtr,float *ccopPtr){

float h, c, hcop, ccop;

ccop= c/ h-c;
hcop= h/ h-c;

printf ("The value of cop for refrigerator cycle = %f\n", ccop);
scanf("%.2f", &ccop);
printf("The value of cop for heat pump = %f\n", hcop);
scanf("%.2f", &hcop);

return;

}

Code tags added by Hammer.