27. Dynamic SensorData Allocation

Back To All Submissions
Previous Submission
Next Submission
#include <iostream>
using namespace std;

// Write your struct and dynamic allocation code here
struct SensorData
{
    int x;
    int y;
    int z;
};

int main() {
    int x, y, z;
    cin >> x >> y >> z;

    // Write your dynamic allocation logic here
    struct SensorData* sensor1 = new SensorData;
    sensor1->x = x;
    sensor1->y = y;
    sensor1->z = z;
    cout<<sensor1->x<<" "<<sensor1->y<<" "<<sensor1->z;
    delete sensor1;
    return 0;
}

Solving Approach

 

 

 

 

 

 

Was this helpful?
Upvote
Downvote