C Program to find the size of the array


This content was proof-read by Grammarly. You can Try Grammary for FREE

This post helps to find the size of the array using the C programming language.

C Program to find the size of the array

#include <stdio.h>
int main() 
{
    int array[5]= { 1, 2, 3, 4, 5 };   
	int size;
	size = sizeof(array)/sizeof(int);
    //Print size of Array
    printf("The Size of Array is %d", size); 
	return 0;
}

Output

Explanation

In this program we get to find the size of the array by assigning the value for array and using a variable.

We calculate the size of the array with the use of sizeof function.

	int array[5]= { 1, 2, 3, 4, 5 };   
	int size;
	size = sizeof(array)/sizeof(int);

Now we progress to displaying the desired result.

	//Print size of Array
    printf("The Size of Array is %d", size); 

We now get the fancied output.

Newsletter Signup

Subscribe to our weekly newsletter below and never miss the latest product or an exclusive offer.

Newsletter Signup

Subscribe to our weekly newsletter below and never miss the latest product or an exclusive offer.

%d bloggers like this: