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

+1 vote
asked 1 day ago by slavik kozakov (150 points)

2 Answers

+3 votes
answered 1 day ago by Peter Minarik (54,560 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 10 hours ago by Colin Broyles (650 points)
On python there is a length function:

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

print(len(x))
+1 vote
answered 16 hours ago 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.
...