Question 2 Construct a C++ program to store the data in column X as an array, then process the data to obtain the data as in column Y and Z. Store the data as an array as well. X Y Z 0 100 95 2 98 93 4 96 91 6 94 89 8 92 87 10 90 85 … … … … … … 100 0 -5
#include <iostream>
using namespace std;
int main(){
int XYZ[101][3];
int counterX=0;
int counterY=100;
int counterZ=95;
for(int i=0;i<51;i++){
XYZ[i][0]=counterX;
XYZ[i][1]=counterY;
XYZ[i][2]=counterZ;
counterX+=2;
counterY-=2;
counterZ-=2;
}
cout<<"X Y Z\n";
for(int i=0;i<51;i++){
for(int j=0;j<3;j++){
cout<<XYZ[i][j]<<" ";
}
cout<<"\n";
}
cin>>counterY;
return 0;
}
Comments
Leave a comment