In this practical assignment you are going to work with arrays in C using the Ar
ID: 3795987 • Letter: I
Question
In this practical assignment you are going to work with arrays in C using the Arduino and the SDU expansion boards. Please upload the code (just the .c file that contains your main function) into blackboard by the given deadline. Add comments to your code about the execution of the program. a. Create an array of 12 elements, where each element will hold the average temperature data for a given month. The user will be prompted to input temperature data from the keyboard for every month. Use a for loop to read these 12 temperatures. b. Write a function that can check if a temperature value is higher than +25 or smaller than -25. Call this function for every time you enter the average temperature for a month and if the input number is out of range, then the user will be prompted to type again the value for that month until it is in the valid range (-25 to 25). c. Write a function that will take a number as an input parameter. The function will list temperatures on the screen and the corresponding month. If the parameter is 0, the function should list the temperatures for every month. If the parameter is 1, the function should list the months where the temperature was positive. If the parameter is -1, the function should list the months where the temperature was negative. Call this function with the parameter 0 if the user presses button 1 Call this function with the parameter 1 if the user presses button 2 Call this function with the parameter -1 if the user presses button 3. d. Implement the functionality such that when the user presses button 4 from the DIO expansion board you will reset all elements from the array to 0 and the program will go back and ask the user to input new temperatures. (This can repeat forever)Explanation / Answer
#include <stdio.h>
int main()
{
printf("Enter Temperature ");
int temperature[12];
int i;
for(i=0;i<12;i++)
{
scanf("%d", &temperature[i]);
}
for (i=0;i<12;i++)
{
if(temperature[i]>-25 && temperature[i]<=25)
{
printf("%d",temperature[i]);
}
else
{
printf("Below range, enter temperature again");
scanf("%d", &temperature);
}
}
return 0;
}
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.