Answer to Question #242802 in C++ for Jun Hao

Question #242802

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.


1
Expert's answer
2021-09-27T04:52:57-0400
#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;
	}
	
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS