Write an interactive C++ program which prompts the user for 10 integers (one at a time) and stores them into a one dimensional array and prints the result. Then the program takes the array and reverses the order of its elements and prints the reversed array. The following is an example of reversing elements of an array.Program requirements:
- The program must contain a class in which all the required private and public identifiers and the following functions must be defined.

- The program must contain three or more functions using parameters

Note:
- At least one of the above functions and identifiers should be private.

Recommended Answers

All 9 Replies

This looks just like the last question you asked. what don't you understand about it?

#include<iostream>

using namespace std;

const int element = 10;

class solution {

	public:
		solution();
		void store (int, int);
		void print(int &, int );
		void sortReverse();

	private:
		int num[element];

};
	
solution::solution(){

	for (int i=0; i<element; i++){
		num[i] = 0;

	}

}

void solution::store(int a, int j){

	num[j] = a;
}

void solution::sortReverse(){

	int temp = 0;

	for(int i=0; i<element; i++){
		for(int j=0; j<element-1; j++)
			if(num[j]<num[j+1]){
				temp = num[j];
				num[j] = num[j+1];
				num[j+1] = temp;

			}

	}

}

void solution::print(int &a, int index){

	a = num[index];
	

}
	
void main(){
	
	int count = 0, num3 = 0, a;
	solution A;
	
	do{
		cout<<"Please enter an integer: ";
		cin>>num3;
		cout<<endl;

		//storing the array using parameter
		A.store(num3,count);

		count ++;

	}while(count<10);

	// Reversing elements of an array
	
	A.sortReverse();

	//Printing the array using parameter
	
	cout<<"Printing the reverse array."<<endl;

	for(int i=0; i<10; i++){

		A.print(a, i);

		cout<<a<<" ";

	}

	cout<<endl;

}
Member Avatar for iamthwee

Don't do other people's homework. Period.

:cool:

Yes i think thats correct but to help someone is not wrong

Yes i think thats correct but to help someone is not wrong

True -- but the OP didn't ask for our help, just stated a problem.:rolleyes:

And besides, doing someone's homework for them isn't actually helping them learn, They're just given the answer with no real understanding gained.

commented: Absolutely! +1

K.......I agree with u.

Ok Can u please help me i swear this is not my homework and only a creation of mine.please help me.it is therein help....lib management program...:rolleyes:
I have created it on my own i swear:eek:

Ok Can u please help me i swear this is not my homework and only a creation of mine.please help me.it is therein help....lib management program...:rolleyes:
I have created it on my own i swear:eek:

Cool -- why are you hijacking this thread? you already have your own thread.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.