C++ Array

Please support our C++ advertiser: Intel Parallel Studio Home
Reply

Join Date: Nov 2004
Posts: 5
Reputation: Faramba is an unknown quantity at this point 
Solved Threads: 0
Faramba Faramba is offline Offline
Newbie Poster

C++ Array

 
0
  #1
Nov 29th, 2004
Please help me with this:
Declare an integer array named "scores" to contain 50 elements.
&
Generate a code (a loop) that will initialize every element in the array from the above declaration("scores") to the value 75.
Reply With Quote Quick reply to this message  
Join Date: Oct 2004
Posts: 4,117
Reputation: vegaseat is just really nice vegaseat is just really nice vegaseat is just really nice vegaseat is just really nice vegaseat is just really nice 
Solved Threads: 944
Moderator
vegaseat's Avatar
vegaseat vegaseat is offline Offline
DaniWeb's Hypocrite

Re: C++ Array

 
0
  #2
Nov 29th, 2004
I hope this is not homework! That would be cheating!
This will do something like that, learn from it:
[php]
#include <iostream>
#include <iomanip> // for setw()
#include <stdlib.h> // for system()

using namespace std;

int main()
{
int k;
int scores[50]; // array to hold 50 integers

// initialize the array
for(k = 0; k < 50; k++)
scores[k] = 75;

// test it
for(k = 0; k < 50; k++)
cout << scores[k] << setw(8);

cout << endl;

system("PAUSE"); // wait
return 0;
}
[/php]
May 'the Google' be with you!
Reply With Quote Quick reply to this message  
Join Date: Nov 2004
Posts: 6,143
Reputation: jwenting is just really nice jwenting is just really nice jwenting is just really nice jwenting is just really nice 
Solved Threads: 213
Team Colleague
jwenting's Avatar
jwenting jwenting is offline Offline
duckman

Re: C++ Array

 
0
  #3
Nov 30th, 2004
of course it's homework.
If it were not it wouldn't be worded as "do this, do that" which is most likely an exact replication of the text of his assignment...
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the C++ Forum
Thread Tools Search this Thread



Tag cloud for C++
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC