Please support our C++ advertiser: Programming Forums
![]() |
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.
- 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.
•
•
Join Date: Jul 2005
Posts: 35
Reputation:
Rep Power: 4
Solved Threads: 0
#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;
}•
•
Join Date: Aug 2005
Location: near St Louis, Missouri, USA
Posts: 11,862
Reputation:
Rep Power: 40
Solved Threads: 1013
•
•
Join Date: Aug 2005
Location: near St Louis, Missouri, USA
Posts: 11,862
Reputation:
Rep Power: 40
Solved Threads: 1013
•
•
•
•
Originally Posted by Cool Nanu
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.
![]() |
Other Threads in the C++ Forum
- Previous Thread: help with loop logic
- Next Thread: homework help please
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)






Linear Mode