Answers for "fill a new array with value c++"

C++
0

fill array c++

#include <iostream>
#include <array>
using namespace std;
main () {
  array<int,6> myarray;
  myarray.fill(5);
  cout << "myarray contains:";
  for (int& x : myarray) { 
      cout << ' ' << x; 
  }
  cout << 'n';
  //myarray contains: 5 5 5 5 5 5
  return 0;
}
Posted by: Guest on May-17-2021

Browse Popular Code Answers by Language