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
What is meant by a delegate?
What does new return if there is insufficient memory to make your new object?
What are the four partitions in which c++ compiler divides the ram?
write a function signature with various number of parameters.
What is the use of ::(scope resolution operator)?
Explain data encapsulation?
what is oops and list its features in c++?
Write a program in c++ to print the numbers from n to n2 except 5 and its multiples
Specify different types of decision control statements?
How do I start a c++ project?
What are the vectors in c++?
What is a driver program?
What is the use of structure in c++?
what are Access specifiers in C++ class? What are the types?
Explain the term memory alignment?