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

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

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

    SensorData *data = new SensorData;
    data->x = x;
    data->y = y;
    data->z = z;

    cout<<data->x<<" "<<data->y<<" "<<data->z<<endl;

	delete data;
    return 0;
}

Solving Approach

 

 

 

 

 

 

Was this helpful?
Upvote
Downvote