Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- Chris Stringham / Christophe_Stringham@my.cuesta.edu
- CIS 231 / Assignment 3
- Cuesta College / R. Scovil
- Sunday 31st Oct 2010
- */
- #include <stdio.h>
- #include <math.h>
- #include <stdlib.h>
- #include <string.h>
- #include <ctype.h>
- #define MAX_FAHR_SIZE 20
- /* function PROTOTYPES go HERE */
- void inputFahrs(double * data, int numFahrs); /*Prompts and inputs numFahr values within the specified range(enforced)*/
- double fahrToCels(double fahr); /*Takes in a Fahrenheit temperature and returns the corresponding Celsius value*/
- void outputFahrs(double * data, int numFahrs); /*Outputs a descriptive header followed by all of the Fahrenheits in ascending order,
- one on a line, alongside the corresponding Celsius value.*/
- void outputAverage(double * data, int numFahrs); /*Outputs the average of all the values in the array in Fahrenheit and Celsius*/
- void outputHighLows(double * data, int numFahrs); /*Outputs the high and low values as both Fahrenheit and Celsius.*/
- void outputStdDev(double * data, int numFahrs); /*Outputs the Standard Deviation of this set of numFahrs Fahrenheit.*/
- int main (void)
- {
- int numFahrs;
- double *data;
- printf("\nEnter how many temperatures you would like to input between 1-20: ");
- scanf("%d", &numFahrs);
- /* check to see if it ís out of range as long as it is, re-input */
- while( (numFahrs < 1) || (numFahrs > 20) )
- {
- printf ("Out of range, please re-enter: ");
- scanf("%d", &numFahrs);
- }
- data = malloc(sizeof(double) * numFahrs);
- inputFahrs(data, numFahrs);
- return 0;
- }
- void inputFahrs(double * data, int numFahrs)
- {
- int i, n = 1;
- for (i = 0; i < numFahrs; i++)
- {
- printf("\nPlease enter Fahrenheit temperature #%d: ", n);
- scanf("%d", data[i]);
- n++;
- while (data[i] < -200 || data[i] > 200)
- {
- printf("Temperature is out of range please re-enter: ");
- scanf("%d", data[i]);
- }
- data[i] = '\0';
- }
- return;
- }
- double fahrToCels(double fahr)
- {
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement