help getting program to work

This is a discussion on help getting program to work within the C Programming forums, part of the General Programming Boards category; I need help getting my progrm to work. I don't know how to do the functions and pointers. Any help ...

  1. #1
    Registered User
    Join Date
    Oct 2002
    Posts
    41

    Exclamation help getting program to work

    I need help getting my progrm to work. I don't know how to do the functions and pointers. Any help would be greatly appreciated!

    PROBLEM STATEMENT:

    Cool it.

    Refrigerators and heat pumps are modeled thermodynamically as reversible (i.e., no frictional effect) cycles that convert work energy to heating or cooling energy. For such cycles, we have a measure of efficiency, the coefficient of performance (cop), that is the ratio of cooling or heating divided by the work input required. The values of cop are as follows:



    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

    Here's what I have:
    Code:
    #include <stdio.h>
    
    void enter_temp(float*, float*);
    void convert (float*, float*);
    void cop (float*, float*, float*, float*);
    
    int main (void){
    
    int selection;
    int again = 1;
    
    printf ("Select your computation, 1 for heat or 2 for refrigerator.");
         scanf("%d", &selection);
    printf ("Continue?? type 1 to continue");
    
    while (selection !=1 && selection !=2) {
    printf ("Select your computation, 1 for heat or 2 for refrigerator.");
         scanf("%d", &selection);}
    
    while (again == 1 ) {
    printf ("Continue?? type 1 to %d", again);
         scanf("%d", &again);
    }
    return 0;
    }
    
    void enter_temp(&h, &c)
    
    {
    
    
    printf ("Enter temperatures for hot and cold reservoirs.\n");
    scanf("%lf%lf", &h, &c);
    
    printf("Temperature must be greater than -273.15 and hot reservoir temperature must be greater than cold reservoir temperature.");
    
    while (temperature > -273.15 && h > c) {
      printf ("Enter temperatures for hot and cold reservoirs.\n");
        scanf("%lf%lf", &h&c);   
    }
    
    }
    
    void convert(&h, &c)
    
    {
    
    printf("Temperature in Celsius = %lf (cold) and %lf (hot) in Celsius", h, c);
    
    kelvin = celsius + 273.15;
    
    printf ("Temperature = %lf, kelvin  (cold) and %lf, kelvin  (hot) in Celsius", h, c);
         scanf("%lf", &kelvin);
    
    }
    
    void cop (&h, &c , &hcop, &ccop){
    
    ccop = c / h - c; //refrigerator cycle
    
    hcop = h / h - c;  //heat pump
    
    if (cop = c / h - c)
     printf (" The value of cop for refrigerator = %lf", ccop);
     scanf("%lf", &ccop);
    else
     printf ("The value of cop for heat pump = %lf", hcop);
     scanf ("%lf", &hcop);
    }
    &#91;code]&#91;/code]tagged by Salem

  2. #2
    Registered User datainjector's Avatar
    Join Date
    Mar 2002
    Posts
    356
    First of all use code tags ..secound well you dont know how to use function ????? Read Read Read
    "I wish i could wish my wishs away"

    "By indirections find directions out" -- William Shakespears

    "Do what thou wilt shall be the whole of the law" -- Crowley "THE BEAST 666"

    Mizra -> love = Death...
    RDB(Rocks yooo)..

    http://www.cbeginnersunited.com

    Are you ready for the Trix ???

  3. #3
    CS Author and Instructor
    Join Date
    Sep 2002
    Posts
    511

    Unhappy

    Yes, please use code tags.

    well... for starters

    Code:
    void enter_temp(&h, &c)
    this is not how you defined a function header with pointers.


    Also, where are you calling your functions???

    Major help here

    Why don't you try to find a book the has functions and pointers or ask your instructor.
    Mr. C: Author and Instructor

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Client-server system with input from separate program
    By robot-ic in forum Networking/Device Communication
    Replies: 3
    Last Post: 01-16-2009, 02:30 PM
  2. BOOKKEEPING PROGRAM, need help!
    By yabud in forum C Programming
    Replies: 3
    Last Post: 11-16-2006, 10:17 PM
  3. threaded program doesn't work?
    By OcTO_VIII in forum Linux Programming
    Replies: 1
    Last Post: 12-11-2003, 11:37 AM
  4. The Bludstayne Open Works License
    By frenchfry164 in forum A Brief History of Cprogramming.com
    Replies: 8
    Last Post: 11-26-2003, 10:05 AM
  5. how does this program work
    By ssjnamek in forum C++ Programming
    Replies: 2
    Last Post: 01-02-2002, 12:48 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21