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

Is c or c++ more useful?

609


What is long in c++?

772


What is a container class?

652


Is c++ the hardest language?

598


Evaluate !(1&&1||1&&0) a) Error b) False c) True

736






What does count ++ do in c++?

725


Explain the difference between c & c++?

621


What is class syntax c++?

633


Can a function take variable length arguments, if yes, how?

597


What is the full form nasa?

621


If you don’t declare a return value, what type of return value is assumed?

571


What is the difference between passing by reference and passing a reference?

599


Write a program using GUI concept for the scheduling algorithms in Operating system like SJF,FCFS etc..

3390


what Is DCS ? what i will get benefit when i did?

1863


How java is different from c and c++?

686