#include void instructions(); void sqByRef(double *num); void sqByVal(double num); int main() { FILE *inputfile; double inputNumber; /* variable holds a double */ double *ptInputNumber; /* variable holds the address of an address containing a double */ ptInputNumber = &inputNumber; /* initalizing pointer so it can be used in scanf*/ instructions(); inputfile = fopen("primes.txt", "r"); while( fscanf(inputfile, "%lf", ptInputNumber)!=EOF) { printf("\n***********************************************"); printf("\nFrom main function: input number => %.2f", *ptInputNumber); sqByVal(*ptInputNumber); printf("\nAfter passed by value: input number => %.2f", *ptInputNumber); sqByRef(ptInputNumber); printf("\nAfter passed by reference: input number => %.2f", *ptInputNumber); }; printf("\n", inputNumber); fclose(inputfile); return 0; } void sqByRef(double *num) { printf("\n\tPassed by reference: %f squared is ", *num); *num = *num * *num; printf("%f", *num); } void sqByVal(double num) { printf("\n\tPassed by value: %.02f squared is ", num); num = num*num; printf("%.2f", num); } void instructions(void) { printf("\n***********************************************************"); printf("\n***** This program pointer manipulation ***"); printf("\n***** ***"); printf("\n***** This program opens the file primes.txt, ***"); printf("\n***** the data read in and printed to the screen. ***"); printf("\n***** Then, the values will be passed to two functions ***"); printf("\n***** one by value, one by reference. ***"); printf("\n***** Open and study the source code to see why the ***"); printf("\n***** values are different. ***"); printf("\n***********************************************************\n"); }