Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR CPP

taking input from user in array in c++

int numbers[5];

  cout << "Enter 5 numbers: " << endl;

  //  store input from user to array
  for (int i = 0; i < 5; ++i) {
    cin >> numbers[i];
  }

  cout << "The numbers are: ";

  //  print array elements
  for (int n = 0; n < 5; ++n) {
    cout << numbers[n] << "  ";
  }

  return 0;
}
 
PREVIOUS NEXT
Tagged: #input #user #array
ADD COMMENT
Topic
Name
5+1 =