C++ Program to Find Number of Elements in Array

Write C++ Program to Find Number of Elements in Array

// CPP Program to Find Number of Elements in Array

#include <iostream>

using namespace std;

int main()
{
	int A[] = {1, 2, 3, 4, 5, 6, 7, 8}, i;
	int n = sizeof(A) / sizeof(A[0]);

        cout << "Array Elements :--> ";
	for(i=0; i<n; i++)
        cout << A[i] << " ";

	cout << "\n\nNumber of Elements in Array :--> " << n;

	return 0;
}

Output:

Array Elements :--> 1  2  3  4  5  6  7  8

Number of Elements in Array :--> 8

≪ Previous | Next ≫