How to declare,initialize and print an int array in C++

1 Answer

0 votes
#include <iostream>

using namespace std;

int main()
{
	int arr[] = { 1, 7, 3, 2, 9, 8 };

	int len = sizeof(arr) / sizeof(arr[0]); 

	for (int i = 0; i < len; i++)
		cout << arr[i] << endl;
		
	return 0;
}


/*
run:

1
7
3
2
9
8

*/

 



answered May 26, 2017 by avibootz

Related questions

2 answers 204 views
2 answers 225 views
...