# Call by Reference

 James Moore · October 23, 2015 Hey guys here is my second program using call by reference... I realize that i have 6 variables to store the difference of the conversion even though its call by reference and it changes the block but i don't know how else id make it so it all prints using a printall function. and earlier i tried to do something like printAll(temp1,convertToFahr(&diff)) but it wouldn't work properly. help me out please  also the assignment is to use call by reference so im assuming my printall function should use call by reference as well, and i dont know how in the world that will work either. Script started on Fri Oct 23 02:00:27 2015:~/CProg/Asn4\$ gcc Assignment1 4. ) _1.c -o test:~/CProg/Asn4\$ ./testEnter Three Fahrenheit temps to convert to Celcious68-40100Enter Three Celcious temps to convert to Fahrenheit20-406 30The Temperture Conversions from Fahrenheit to Celcious are  Fahrenheit | Celsious68.00 | 20.00 -40.00 | -40.00 100.00 | 37.78 The Temperture Conversions from Celsious to Fahrenheit are  Celsious | Fahrenheit20.00 | 68.00 -40.00 | -40.00 30.00 | 86.00 Script done on Fri Oct 23 02:01:11 2015#include #include #include #include #include // function prototypesfloat convertToCelcious(float, float *);float convertToFahr(float, float *); void printAll(float temp, float funk); int main(){   // Variables for tempertures and differences after conversions      float temp1,temp2,temp3;     float diff1,diff2,diff3;        float temp4,temp5,temp6;     float diff4,diff5,diff6;     printf("Enter Three Fahrenheit temps to convert to Celcious\n");scanf("%f %f %f",&temp1,&temp2,&temp3);printf("Enter Three Celcious temps to convert to Fahrenheit\n"); scanf("%f %f %f",&temp4,&temp5,&temp6);// Call to convertToCelciousconvertToCelcious(temp1,&diff1); convertToCelcious(temp2,&diff2);convertToCelcious(temp3,&diff3);// Calls to convertToFahrconvertToFahr(temp4,&diff4); convertToFahr(temp5,&diff5);convertToFahr(temp6,&diff6);// Beggining of table of print outs printf("The Temperture Conversions from Fahrenheit to Celcious are \n "); printf("Fahrenheit \t | Celsious\n"); printAll(temp1,diff1); printAll(temp2,diff2);printAll(temp3,diff3);printf("The Temperture Conversions from Celsious to Fahrenheit are \n "); printf("Celsious \t | Fahrenheit\n"); printAll(temp4,diff4);printAll(temp5,diff5);printAll(temp6,diff6);     return 0; }// Function Deffinitions // Deffinition for convertToCelciousfloat convertToCelcious(float temp, float *diff){    *diff = (temp - 32) / 1.8000;}// Deffinition for convertToFahrfloat convertToFahr(float temp, float *diff){    *diff = temp * 9 / 5 + 32;}// Deffinition for printAll function void printAll(float temp, float funk){    printf("%.2f \t \t | %.2f \n", temp, funk);         return; }

## Replies

Nothing to see here.

## C

129,672 followers