Dynamic SensorData Allocation

#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* data= new Sensordata[3];
     
     data->x= x;
     data->y= y;
     data->z= z;

     cout<<data->x<<" "<<data->y<<" "<<data->z;
    delete data;
    return 0;
}

Solving Approach

 

 

 

 

 

 

Upvote
Downvote
Loading...

Input

3 4 5

Expected Output

3 4 5