Skip to main content

Simple C++ Program for Find Array Size

1 min read Updated June 30, 2026
Share:
On this page (8sections)

About this program

This is an example program in c array example programs. Read the concept first: Understanding Array in C++, then study the code and output below.

Definition

An array is a collection of data that holds homogeneous values. That means values should be in same type

Array Syntax

type variable_name[size]

Sizeof Syntax

sizeof(data_type)

Simple C++ Program for Find Array Size

/*## Simple C++ Program for Find Array Size */
/*## Simple Array Programs In C++,Find Array Size C++ Programming,sizeof Example*/

// Header Files
#include <iostream>
#include<conio.h>

using namespace std;
 
int main() {

	// Declare Array Variable
    int array[5]= { 1, 2, 3, 4, 5 };
    
    //Read Day Value
	int size;
	
	cout<<"Simple C++ Example Program for Simple C++ Program for Find Array Size\n";
	
	size = sizeof(array)/sizeof(int);

    //Print size of Array
    cout<<"The Size of Array is "<<size;
    
   getch();
	return 0;
}

Sample Output

The Size of Array is 5

Learn the concept first, then study the code:

Frequently Asked Questions

What does this C++ program do?
It is a C++ example program that demonstrates Simple Program for Find Array Size, including the complete source code and the expected sample output.
How do I compile and run this C++ program?
Save the code in a `.cpp` file, compile it with `g++ filename.cpp -o program`, then run it with `./program` (or `program.exe` on Windows).
What concepts does this example use?
This example uses arrays, illustrating a common pattern in C++ programming.

Related Tutorials

Search tutorials