Advertisement
Guest User

Untitled

a guest
Jun 24th, 2017
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.01 KB | None | 0 0
  1. /*
  2. Chris Stringham / Christophe_Stringham@my.cuesta.edu
  3. CIS 231 / Assignment 3
  4. Cuesta College / R. Scovil
  5. Sunday 31st Oct 2010
  6. */
  7.  
  8. #include <stdio.h>
  9. #include <math.h>
  10. #include <stdlib.h>
  11. #include <string.h>
  12. #include <ctype.h>
  13.  
  14. #define MAX_FAHR_SIZE 20
  15.  
  16. /* function PROTOTYPES go HERE */
  17.  
  18. void inputFahrs(double * data, int numFahrs); /*Prompts and inputs numFahr values within the specified range(enforced)*/
  19.  
  20. double fahrToCels(double fahr); /*Takes in a Fahrenheit temperature and returns the corresponding Celsius value*/
  21.  
  22. void outputFahrs(double * data, int numFahrs); /*Outputs a descriptive header followed by all of the Fahrenheits in ascending order,
  23. one on a line, alongside the corresponding Celsius value.*/
  24.  
  25. void outputAverage(double * data, int numFahrs); /*Outputs the average of all the values in the array in Fahrenheit and Celsius*/
  26.  
  27. void outputHighLows(double * data, int numFahrs); /*Outputs the high and low values as both Fahrenheit and Celsius.*/
  28.  
  29. void outputStdDev(double * data, int numFahrs); /*Outputs the Standard Deviation of this set of numFahrs Fahrenheit.*/
  30.  
  31. int main (void)
  32. {
  33. int numFahrs;
  34. double *data;
  35.  
  36. printf("\nEnter how many temperatures you would like to input between 1-20: ");
  37. scanf("%d", &numFahrs);
  38.  
  39. /* check to see if it ís out of range as long as it is, re-input */
  40.  
  41. while( (numFahrs < 1) || (numFahrs > 20) )
  42. {
  43. printf ("Out of range, please re-enter: ");
  44. scanf("%d", &numFahrs);
  45. }
  46.  
  47. data = malloc(sizeof(double) * numFahrs);
  48.  
  49.  
  50. inputFahrs(data, numFahrs);
  51.  
  52.  
  53. return 0;
  54. }
  55.  
  56. void inputFahrs(double * data, int numFahrs)
  57. {
  58. int i, n = 1;
  59.  
  60. for (i = 0; i < numFahrs; i++)
  61. {
  62. printf("\nPlease enter Fahrenheit temperature #%d: ", n);
  63. scanf("%d", data[i]);
  64. n++;
  65.  
  66. while (data[i] < -200 || data[i] > 200)
  67. {
  68. printf("Temperature is out of range please re-enter: ");
  69. scanf("%d", data[i]);
  70. }
  71.  
  72. data[i] = '\0';
  73. }
  74. return;
  75. }
  76.  
  77. double fahrToCels(double fahr)
  78. {
  79.  
  80. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement