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,y,z;
};

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

    // Write your dynamic allocation logic here
    SensorData * obj = new SensorData;
    obj->x=x;
    obj->y=y;
    obj->z=z;
    cout<<obj->x<<" "<<obj->y<<" "<<obj->z;

    delete obj;

    return 0;
}

Solving Approach

 

 

 

 

 

 

Was this helpful?
Upvote
Downvote