How can you quickly find the number of elements stored in a
a) static array b) dynamic array ?

Answer Posted / santhosh kumar sahukari

1.for static array we can find the no.of elements of its by using sizeof() operator and data type of that array.
2.we can find the no.of elements by its subscript in static array.
eg: int arr[10]
we can use sizeof(arr) to find the no.of elements it v l print 20,then we can divide it by 2 as size of int is 2.
2.subscript tells us it has 10 elements.

for dynamic array we cant use sizeof() operator.
we cant say dat how many elements it will have..it will be decided at runtime only.

Is This Answer Correct ?    4 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What does return 0 do in c++?

584


What is linked list in c++?

697


Can I learn c++ without learning c?

568


What is the outcome of cout< a) 16 b) 17 c) 16.5

629


Does c++ have arraylist?

550






What is the error in the code below and how should it be corrected?

313


What is data hiding c++?

605


What is setiosflags c++?

537


How delete [] is different from delete?

604


What is scope resolution operator in c++ with example?

563


What are the extraction and insertion operators in c++?

568


Which software is used for c++ programming?

623


Do we have to use initialization list in spite of the assignment in constructors?

573


What is the copy-and-swap idiom?

614


What is stream and its types in c++?

564