C/C++ Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 
Go Back   Dev Articles Community ForumsProgrammingC/C++ Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
  #1  
Old December 7th, 2004, 12:47 PM
maro009 maro009 is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Nov 2004
Posts: 6 maro009 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
test array

hi guys
i hope this one is legal this time ,
howcan i test if the numbers in array are all equal ,,

and also how can i know the first and the middin and the last number
in array,

Reply With Quote
  #2  
Old December 7th, 2004, 02:17 PM
MadCowDzz's Avatar
MadCowDzz MadCowDzz is offline
I'm Internet Famous
Dev Articles Frequenter (2500 - 2999 posts)
 
Join Date: Jan 2003
Location: Toronto, Canada
Posts: 2,890 MadCowDzz User rank is Lance Corporal (50 - 100 Reputation Level)MadCowDzz User rank is Lance Corporal (50 - 100 Reputation Level)MadCowDzz User rank is Lance Corporal (50 - 100 Reputation Level) 
Time spent in forums: 1 Week 16 h 14 m 9 sec
Reputation Power: 8
Try google'ing for simple tutorials about using Arrays in C++
This one is a decent start: http://cplus.about.com/od/beginnerc...l/aa050102a.htm

Reply With Quote
  #3  
Old December 9th, 2004, 11:17 PM
Evoltix Evoltix is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Oct 2004
Location: Nebraska
Posts: 14 Evoltix User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Send a message via AIM to Evoltix Send a message via Yahoo to Evoltix
Code:
include <iostream>
using namespace std;
 
int main()
{
	 const int arraySize = 100;
	 int array[arraySize];
	 int size;
	 int middle;
 
	 cout << "How many elements will the array have? ";
	 cin >> size;
 
	 //Initialize all elements of the array to 0.
 
	 for(int cntr = 0; cntr < size; cntr++)
	 {
		 array[cntr] = 0;
	 }
 
	 cout << endl;
 
	 // Here you can ask the user if they want to input
	 // the array elements via cin >> in a for loop.
 
	 middle = (size/2) - 1;
 
	 cout << "First element: " << array[0] << endl;
	 cout << "Middle element: " << array[middle] << endl;
	 cout << "Last element: " << array[size - 1] << endl;
 
	 return 0;
}

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgrammingC/C++ Help > test array


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 5 hosted by Hostway