Simple C Program for Find Array Size
On this page (9sections)
About this program
This is an example program in c array example programs. Read the concept first: C Array, 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,Find Array Size C Programming, sizeof Example*/
#include <stdio.h>
int main() {
// Declare Array Variable
int array[5]= { 1, 2, 3, 4, 5 };
//Read Day Value
int size;
size = sizeof(array)/sizeof(int);
//Print size of Array
printf("The Size of Array is %d", size);
return 0;
}
Sample Output:
The Size of Array is 5
How It Works
This C program demonstrates Simple C Program for Find Array Size. It first prepares the data it needs, then performs the core operation step by step, and finally prints the output shown in the Sample Output above.
- Declare the variables that hold the program’s data.
- Print the final result to the console so you can compare it with the sample output.
Try changing the input values and re-running the program to see how the output changes — this is the fastest way to understand how the logic behaves.
Related Pages
Learn the concept first, then study the code:
- C Programs — Browse all C Programs.
- C Array — Concept — arrays, indexing and multidimensional arrays.
- Single Dimensional Array Example Program in C Programming — More in c array example programs.
- Sum of Array C Example Program — More in c array example programs.
Frequently Asked Questions
What does this C program do?
It is a C example program that demonstrates Simple C 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 `.c` file, compile it with `gcc filename.c -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.