Unit 4 Notes
Unit 4 Notes
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
int main() {
srand(time(NULL)); // Seed random number generator
for (int i = 0; i < 10; i++) { // Simulate 10 readings
printf("Current Temperature: %.2f °C\n", readTemperature());
sleep(1); // Wait 1 second between readings
}
return 0;
}
Explanation
1. Includes: Standard libraries for I/O, random numbers, and time.
2. Temperature Function: Simulates a temperature reading.
3. Main Loop: Generates and prints 10 random temperature readings,
pausing for 1 second between each.