RSS Forums RSS
Please support our C++ advertiser: Programming Forums
Views: 1189 | Replies: 9 | Thread Tools  Display Modes
Reply
Join Date: Mar 2006
Location: NEW ORLEANS
Posts: 5
Reputation: Tiffiney_v24 is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
Tiffiney_v24's Avatar
Tiffiney_v24 Tiffiney_v24 is offline Offline
Newbie Poster

I Need Help!!

  #1  
May 2nd, 2006
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.
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Feb 2006
Location: UK
Posts: 479
Reputation: Bench has a spectacular aura about Bench has a spectacular aura about Bench has a spectacular aura about 
Rep Power: 5
Solved Threads: 47
Bench's Avatar
Bench Bench is offline Offline
Posting Pro in Training

Re: I Need Help!!

  #2  
May 2nd, 2006
This looks just like the last question you asked. what don't you understand about it?
Reply With Quote  
Join Date: Jul 2005
Posts: 35
Reputation: k_en is an unknown quantity at this point 
Rep Power: 4
Solved Threads: 0
k_en k_en is offline Offline
Light Poster

Re: I Need Help!!

  #3  
May 2nd, 2006
#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;

}
Reply With Quote  
Join Date: Aug 2005
Posts: 4,844
Reputation: iamthwee is a glorious beacon of light iamthwee is a glorious beacon of light iamthwee is a glorious beacon of light iamthwee is a glorious beacon of light iamthwee is a glorious beacon of light 
Rep Power: 17
Solved Threads: 325
iamthwee's Avatar
iamthwee iamthwee is offline Offline
Industrious Poster

Re: I Need Help!!

  #4  
May 3rd, 2006
Don't do other people's homework. Period.

Reply With Quote  
Join Date: May 2006
Location: Bhopal
Posts: 10
Reputation: Cool Nanu is an unknown quantity at this point 
Rep Power: 3
Solved Threads: 0
Cool Nanu's Avatar
Cool Nanu Cool Nanu is offline Offline
Newbie Poster

Re: I Need Help!!

  #5  
May 7th, 2006
Yes i think thats correct but to help someone is not wrong
Reply With Quote  
Join Date: Aug 2005
Location: near St Louis, Missouri, USA
Posts: 11,862
Reputation: Ancient Dragon has much to be proud of Ancient Dragon has much to be proud of Ancient Dragon has much to be proud of Ancient Dragon has much to be proud of Ancient Dragon has much to be proud of Ancient Dragon has much to be proud of Ancient Dragon has much to be proud of Ancient Dragon has much to be proud of Ancient Dragon has much to be proud of Ancient Dragon has much to be proud of 
Rep Power: 40
Solved Threads: 1013
Moderator
Featured Poster
Ancient Dragon's Avatar
Ancient Dragon Ancient Dragon is offline Offline
Most Valuable Poster

Re: I Need Help!!

  #6  
May 7th, 2006
Originally Posted by Cool Nanu
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:
Reply With Quote  
Join Date: Feb 2006
Location: UK
Posts: 479
Reputation: Bench has a spectacular aura about Bench has a spectacular aura about Bench has a spectacular aura about 
Rep Power: 5
Solved Threads: 47
Bench's Avatar
Bench Bench is offline Offline
Posting Pro in Training

Re: I Need Help!!

  #7  
May 7th, 2006
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.
Reply With Quote  
Join Date: May 2006
Location: Bhopal
Posts: 10
Reputation: Cool Nanu is an unknown quantity at this point 
Rep Power: 3
Solved Threads: 0
Cool Nanu's Avatar
Cool Nanu Cool Nanu is offline Offline
Newbie Poster

Re: I Need Help!!

  #8  
May 7th, 2006
K.......I agree with u.
Reply With Quote  
Join Date: May 2006
Location: Bhopal
Posts: 10
Reputation: Cool Nanu is an unknown quantity at this point 
Rep Power: 3
Solved Threads: 0
Cool Nanu's Avatar
Cool Nanu Cool Nanu is offline Offline
Newbie Poster

Re: I Need Help!!

  #9  
May 7th, 2006
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:
Reply With Quote  
Join Date: Aug 2005
Location: near St Louis, Missouri, USA
Posts: 11,862
Reputation: Ancient Dragon has much to be proud of Ancient Dragon has much to be proud of Ancient Dragon has much to be proud of Ancient Dragon has much to be proud of Ancient Dragon has much to be proud of Ancient Dragon has much to be proud of Ancient Dragon has much to be proud of Ancient Dragon has much to be proud of Ancient Dragon has much to be proud of Ancient Dragon has much to be proud of 
Rep Power: 40
Solved Threads: 1013
Moderator
Featured Poster
Ancient Dragon's Avatar
Ancient Dragon Ancient Dragon is offline Offline
Most Valuable Poster

Re: I Need Help!!

  #10  
May 7th, 2006
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.
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.



Other Threads in the C++ Forum
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

Thread Tools Display Modes
Forums | Blogs | Tutorials | Code Snippets | Whitepapers | RSS Feeds | Advertising
All times are GMT -4. The time now is 1:10 am.
Newsletter Archive - Sitemap - Privacy Statement - Acceptable Use Policy - Contact Us
Forum system based on vBulletin Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC