Last active
June 4, 2020 03:47
-
-
Save dschinkel/b6a319d730e4651f73d42079317ad33c to your computer and use it in GitHub Desktop.
C Example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#define _CRT_SECURE_NO_WARNINGS | |
#include <stdio.h> | |
#define NUMBER_OF_DAYS 3 | |
// Put your code below: | |
int main(void) | |
{ | |
int k, highEntry, lowEntry; | |
printf("-- -= == IPC Temperature Analyzer == = --\n"); | |
for (int i = 1; i < NUMBER_OF_DAYS; i++) | |
{ | |
Array entries = promptForTemperature(); | |
bool isValid = validateInput(entries[1], entries[0]) | |
if(isValid) break; | |
main(); | |
} | |
} | |
promptForTemparature(){ | |
printf("Enter the high value for day %d: ", i); | |
scanf("%d", &highEntry); | |
printf("Enter the low value for day %d: ", i); | |
scanf("%d", &lowEntry); | |
return [highEntry, lowEntry] | |
} | |
validateInput(lowEntry, highEntry){ | |
if (highEntry > 42 || lowEntry < -42); | |
{ | |
printf("Incorrect values, temperatures must be in the range 41 to -41, high must be greater than low.\n"); | |
--i; | |
return false; | |
} | |
return true; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment