CPP program to initialize an array with consecutive numbers

Suman Barik
0
// CPP program to initialize an array with consecutive
// numbers
#include <iostream>
#include <numeric>
using namespace std;

int main()
{
int arr[5];
iota(arr, arr + 5, 1);
for (int i = 0; i < 5; i++) {
cout << arr[i] << " ";
}
return 0;
}

Tags

Post a Comment

0Comments
Post a Comment (0)