0

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.

3
Contributors
2
Replies
4
Views
12 Years
Discussion Span
Last Post by jwenting
0

I hope this is not homework! That would be cheating!
This will do something like that, learn from it:

#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;
}
0

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...

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.