Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "stdio.h"
- /*Use a function to print a Fahrenheit-Celsius conversion table using the formula C=(5/9)*(F-32) with a step of 20 between values of 0 t 300 of Fahrenheit temperatures*/
- #define STEP 20
- int Convert(int f);
- main()
- {
- int i, sum=0;
- int fahrenheitValues[16]; //16 is a result of dividing the maximum value of 300 by a step of 20
- for (i=0;i<16;++i)
- {
- if (i!=0)
- {
- sum=sum+STEP;
- }
- fahrenheitValues[i]=sum;
- printf("%d\t%d\n",fahrenheitValues[i],Convert(fahrenheitValues[i]));
- }
- }
- int Convert (int f)
- {
- int c;
- c=5*(f-32)/9;
- return c;
- }
- /* Matt's comments:
- -16 is a magic number, should have written a comment about it or written it as MAX/STEP+1
- -Don't call arrays array..
- */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement