Design and code an ANSI Standard C program which enhances the code below only so as to make it a modular program. (each of the program four tasks of ask, get, alter and display are now separate functions).
This will necessitate designing appropriate ask, get, alter and display functions. It will also necessitate coding four ANSI Standard function prototypes, function calls in main() and single-task function definitions. Explain in a brief function comment, what the function's task is and if it needs to have data passed into it, if it needs to return a value to the method that called it (main) or possibly both or neither.
Do not use any global variables, only local variables - in other words, declare all your variables inside and at the top of your functions, to include main().
Code to enhance:
printf("Enter the Fahrenheit temperature as a whole number: ");
celsius = 5.0/9.0*(fahrenheit - 32);
printf("Fahrenheit temperature %0.2fn",fahrenheit);
printf("Celsius temperature %0.2fn",celsius);
Using functions is a useful and powerful aspect to a C program. To use a function you must first declare the function using a function prototype. Then you must provide an implementation for the function.
The function prototype includes the name of the function, the return type, and a list of any parameters that the function takes. This posting requires four ...
This solution starts with a C program that converts Fahrenheit to Celsius temperatures using the standard simple approach. It then shows how to rewrite the program using functions for the basic steps in the algorithm. Complete C source code is provided.