Hello, OnlineGDB Q&A section lets you put your programming query to fellow community users. Asking a solution for whole assignment is strictly not allowed. You may ask for help where you are stuck. Try to add as much information as possible so that fellow users can know about your problem statement easily.

how to check the size of array

+2 votes
asked Jun 23 by slavik kozakov (210 points)

2 Answers

+3 votes
answered Jun 23 by Peter Minarik (58,190 points)

What language are you after?

You can use the sizeof() function in C/C++:

#include <stdio.h>

int main()
{
    int array[32];
    printf("Size of array: %lu\n", sizeof(array));
    printf("Element count in array: %lu\n", sizeof(array) / sizeof(array[0]));
    return 0;
}

In other object-oriented languages, such as Java, C#, you typically have a Length or Count property on collections.

commented Jun 24 by Colin Broyles (730 points)
On python there is a length function:

x = (1, 2, 3, 4, 5)

print(len(x))
+1 vote
answered Jun 24 by SojitraDarsh05 (160 points)

using this Method in Swift

var a = [4,53,45,32,67]

print(a.count)

Welcome to OnlineGDB Q&A, where you can ask questions related to programming and OnlineGDB IDE and and receive answers from other members of the community.
...