#include void instructions(); void sqByRef(double *num); void sqByVal(double num); int main() { FILE *inputfile; double inputNumber; instructions(); inputfile = fopen("primes.txt", "r"); while( fscanf(inputfile, "%lf", &inputNumber)!=EOF) { printf("\n***********************************************"); printf("\nFrom main function: input number => %.2f", inputNumber); sqByVal(inputNumber); printf("\nAfter passed by value: input number => %.2f", inputNumber); sqByRef(&inputNumber); printf("\nAfter passed by reference: input number => %.2f", inputNumber); }; 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 demos pointer manipulation ***"); printf("\n***** ***"); printf("\n***** This program opens the file primes.txt ***"); printf("\n***** This is an existing file. ***"); printf("\n***** This file will be opened and the data ***"); printf("\n***** 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***** Various values will be printed to screen ***"); printf("\n***** open and study the source code to see why the ***"); printf("\n***** values are different. ***"); printf("\n***********************************************************\n"); }