Assigning and Displaying Array Values : Array « Data Structure « C++






Assigning and Displaying Array Values

Assigning and Displaying Array Values
 

#include <iostream>

using namespace std;

int main ()
{
   int testScore[3];

   cout << "Enter test score #1: ";

   cin >> testScore[0];

   cout << "Enter test score #2: ";

   cin >> testScore[1];

   cout << "Enter test score #3: ";

   cin >> testScore[2];

   cout << "Test score #1: " << testScore[0] << endl;

   cout << "Test score #2: " << testScore[1] << endl;

   cout << "Test score #3: " << testScore[2] << endl;
   return 0;
}

           
         
  








Related examples in the same category

1.Using a Variable Pointer to Point to an ArrayUsing a Variable Pointer to Point to an Array
2.Array InitializationArray Initialization
3.Using the cin and cout Objects with ArraysUsing the cin and cout Objects with Arrays
4.cin and cout work with char arraycin and cout work with char array
5.Outputs addresses and values of array elements.Outputs addresses and values of array elements.
6.To input numbers into an array and output after.To input numbers into an array and output after.
7.Array based on int pointer