For this Project, you will create a function caled getiemperatureso. The getiemp
ID: 3590597 • Letter: F
Question
For this Project, you will create a function caled getiemperatureso. The getiemperaturesO Tunction will have one parameter called temperatures[]Within the get·Temperatures() function you will populate the temperatures array with the following values: 10,15,20,25,30,32,40,45,50,55,60,65,70. Your main program will traverse through the array and display the Fahrenheit and Celsius equivalents. EXPECTED OUTPUT 10 degrees Fahrenheit is -12 degrees Celsius 10 degrees Celsius is 50 degrees Fahrenheit 15 degrees Fahrenheit is -9 degrees Celsius 15 degrees Celsius is 59 degrees Fahrenheit 20 degrees Fahrenheit is -6 degrees Celsius 20 degrees Celsius is 68 degrees Fahrenheit 25 degrees Fahrenheit is -3 degrees Celsius 25 degrees Celsius is 77 degrees Fahrenheit 30 degrees Fahrenheit is-1 degrees Celsius 30 degrees Celsius is 86 degrees Fahrenheit 35 degrees Fahrenheit is 1 degrees Ceisius 35 degrees Celsius is 95 degrees Fahrenheit 40 degrees Fahrenheit is 4 degrees Celsius 40 degrees Celsius is 104 degrees FahrenheitExplanation / Answer
#define _CRT_SECURE_NO_DEPRECATE
#include<stdio.h>
//this function return populates temperature array with values
void getTemperatures(int temperatures[]);
//array size
const int size = 13;
int main()
{
int temperatures[13];
//declare variable to hold iteration value in for loop
int i;
float celcius,fahren;
//call getTemperatures
getTemperatures(temperatures);
//display the results, formula to calculate farhenheit is T(°F) = T(°C) × 1.8 + 32 ,,from this we can calculate T(°C) = (T(°F) -32)/1.8
for (i = 0; i < size; i++)
{
//convert to celcius
celcius = ((temperatures[i] - 32) *5)/9;
//convert celcius to fahrenheit
fahren = (temperatures[i] *9) / 5 + 32;
printf("%d degress Fahrenheit is %.0f degress Celcius ", temperatures[i], celcius);
printf("%d degress Celcius is %.0f degress Fahrenheit ", temperatures[i], fahren);
}
}
void getTemperatures(int temperatures[])
{
int num = 10;
int i;
for ( i = 0; i< size; i++)
{
if ( i == 0)
temperatures[i] = num ;
else
temperatures[i] = temperatures[i-1]+ 5;
}
}
--------------------------------------------------------------------------------------------------------------------
//output:
10 degress Fahrenheit is -12 degress Celcius
10 degress Celcius is 50 degress Fahrenheit
15 degress Fahrenheit is -9 degress Celcius
15 degress Celcius is 59 degress Fahrenheit
20 degress Fahrenheit is -6 degress Celcius
20 degress Celcius is 68 degress Fahrenheit
25 degress Fahrenheit is -3 degress Celcius
25 degress Celcius is 77 degress Fahrenheit
30 degress Fahrenheit is -1 degress Celcius
30 degress Celcius is 86 degress Fahrenheit
35 degress Fahrenheit is 1 degress Celcius
35 degress Celcius is 95 degress Fahrenheit
40 degress Fahrenheit is 4 degress Celcius
40 degress Celcius is 104 degress Fahrenheit
45 degress Fahrenheit is 7 degress Celcius
45 degress Celcius is 113 degress Fahrenheit
50 degress Fahrenheit is 10 degress Celcius
50 degress Celcius is 122 degress Fahrenheit
55 degress Fahrenheit is 12 degress Celcius
55 degress Celcius is 131 degress Fahrenheit
60 degress Fahrenheit is 15 degress Celcius
60 degress Celcius is 140 degress Fahrenheit
65 degress Fahrenheit is 18 degress Celcius
65 degress Celcius is 149 degress Fahrenheit
70 degress Fahrenheit is 21 degress Celcius
70 degress Celcius is 158 degress Fahrenheit