943,993 Members | Top Members by Rank

Ad:
  • C++ Discussion Thread
  • Unsolved
  • Views: 4941
  • C++ RSS
Nov 29th, 2004
0

C++ Array

Expand Post »
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.
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
Faramba is offline Offline
5 posts
since Nov 2004
Nov 29th, 2004
0

Re: C++ Array

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]
Moderator
Reputation Points: 1333
Solved Threads: 1403
DaniWeb's Hypocrite
vegaseat is offline Offline
5,792 posts
since Oct 2004
Nov 30th, 2004
0

Re: C++ Array

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...
Team Colleague
Reputation Points: 1658
Solved Threads: 331
duckman
jwenting is offline Offline
7,719 posts
since Nov 2004

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in C++ Forum Timeline: c++ arrays, help identify element place
Next Thread in C++ Forum Timeline: C++ strcmp





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC