C Board  

Go Back   C Board > General Programming Boards > C++ Programming

Reply
 
LinkBack Thread Tools Display Modes
Old 02-01-2009, 04:30 PM   #1
Registered User
 
Join Date: Feb 2009
Posts: 3
beginner here need help with an array code

hey im a beginner to C++ and I'm looking for a bit of help in one of my programs, I havent done much with arrays in C++ but I'm looking to get an array of 10 randomly assigned integers, find a way to add them together and print out the result, as well as add all the numbers of the even index of the array and subtract all the numbers in the odd index of the array and put those in two different results. Can someone walk me through this?
Ohshtdude is offline   Reply With Quote
Old 02-01-2009, 04:58 PM   #2
Kernel hacker
 
Join Date: Jul 2007
Location: Farncombe, Surrey, England
Posts: 15,686
Right. The homework policy here at Cprogramming.com is that you show us what you've done and we will help you - not "Post your homework assignment and someone will post back the answer".

-.
Mats
__________________
Compilers can produce warnings - make the compiler programmers happy: Use them!
Please don't PM me for help - and no, I don't do help over instant messengers.
matsp is offline   Reply With Quote
Old 02-01-2009, 05:05 PM   #3
Registered User
 
Join Date: Feb 2009
Posts: 3
sorry

Last edited by Ohshtdude; 02-01-2009 at 08:07 PM.
Ohshtdude is offline   Reply With Quote
Old 02-01-2009, 05:15 PM   #4
and the Hat of Guessing
 
tabstop's Avatar
 
Join Date: Nov 2007
Posts: 8,740
If you are dealing with a[i], how can you tell whether i is even or odd?
tabstop is offline   Reply With Quote
Old 02-01-2009, 05:37 PM   #5
Registered User
 
Join Date: Feb 2009
Posts: 3
no like a[0] being even a[1] being odd a[2] being even etc
Ohshtdude is offline   Reply With Quote
Old 02-01-2009, 05:41 PM   #6
Registered User
 
Join Date: Dec 2006
Posts: 1,780
how about adding 2 in each iteration?
cyberfish is offline   Reply With Quote
Old 02-01-2009, 05:42 PM   #7
and the Hat of Guessing
 
tabstop's Avatar
 
Join Date: Nov 2007
Posts: 8,740
Quote:
Originally Posted by Ohshtdude View Post
no like a[0] being even a[1] being odd a[2] being even etc
Right. So how do you know that 0 is even, 1 is odd, 2 is even, etc?
tabstop is offline   Reply With Quote
Reply

Tags
arrays, beginner

Thread Tools
Display Modes

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
allocation and reallocation of memory dynamically of an integer array zamir C++ Programming 16 05-29-2009 07:25 PM
array of pointers/pointer arithmetic tlpog C Programming 18 11-09-2008 07:14 PM
Dynamic array of structures containing yet another dynamic array of structures innqubus C Programming 2 07-11-2008 07:39 AM
beginner: dynamic array of strings pc2-brazil C++ Programming 10 04-29-2008 04:29 PM
question about multidimensional arrays richdb C Programming 22 02-26-2006 09:51 AM


All times are GMT -6. The time now is 10:25 AM.


Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.3.0 RC2

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22