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.
#include<iostream>
using namespace std;
int main(){
cout<<"Elements in column X are:\n";
int arr[51];
int index = 0;
for(int i=0, x=0; i<101; i++){
if(i%2==0 || i==0){
arr[x] = i;
x++;
}
}
for(int i=0; i<51; i++){
cout<<arr[i]<<endl;
}
int arr_Y[51];
for(int i=50 , j = 0; i>=0; i--){
arr_Y[j] = arr[i];
j++;
}
cout<<"Elements in column Y are:\n";
for(int i=0; i<51; i++){
cout<<arr_Y[i]<<endl;
}
int arr_Z[51];
for(int i=50 , j = 0; i>=0; i--){
arr_Z[j] = arr[i]-5;
j++;
}
cout<<"Elements in column Z are:\n";
for(int i=0; i<51; i++){
cout<<arr_Z[i]<<endl;
}
}
Comments
Leave a comment