-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstruct.cpp
More file actions
44 lines (33 loc) · 866 Bytes
/
struct.cpp
File metadata and controls
44 lines (33 loc) · 866 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
//
// Created by haris on 12/23/2025.
//
#include "struct.h"
#include <iostream>
using namespace std;
struct SensorData {
float temperature; // °C
float voltage; // V
bool error; // fault flag
};
SensorData readSensor() {
SensorData data;
// Simulated sensor values
data.temperature = 36.5;
data.voltage = 2.9;
// Error condition
data.error = (data.voltage < 3.0);
return data;
}
void printStatus(const SensorData& data) {
cout << "Temperature: " << data.temperature << " C" << endl;
cout << "Voltage: " << data.voltage << " V" << endl;
if (data.error) {
cout << "⚠ ERROR: Voltage too low!" << endl;
} else {
cout << "Status: OK" << endl;
}
}
int main() {
SensorData hdd = readSensor();
printStatus(hdd);
}