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.


Are you a .NET Developer planning to integrate GraphQL for .NET in your Application? Check out this book

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.

%d bloggers like this: