ALLInterview.com :: Home Page KalAajKal.com
 Advertise your Business Here     
Browse  |   Placement Papers  |   Company  |   Code Snippets  |   Certifications  |   Visa Questions
Post Question  |   Post Answer  |   My Panel  |   Search  |   Articles  |   Topics  |   ERRORS new
   Refer this Site  Refer This Site to Your Friends  Site Map  Bookmark this Site  Set it as your HomePage  Contact Us     Login  |  Sign Up                      
info       Did you received any Funny E-Mails from your Friends and like to share with rest of our friends? Yeah!! you can post that stuff   HERE
Google
 
Categories  >>  Software  >>  Programming Languages  >>  C++  >>  C++ General
 
 


 

 
 STL interview questions  STL Interview Questions
 OOPS interview questions  OOPS Interview Questions
 C++ General interview questions  C++ General Interview Questions
Question
How can you quickly find the number of elements stored in a 
a) static array b) dynamic array ?
 Question Submitted By :: Tina Saha
I also faced this Question!!     Rank Answer Posted By  
 
  Re: How can you quickly find the number of elements stored in a a) static array b) dynamic array ?
Answer
# 1
static array
 
Is This Answer Correct ?    0 Yes 0 No
Guest
 
  Re: How can you quickly find the number of elements stored in a a) static array b) dynamic array ?
Answer
# 2
for static array start from highest index to lowest ( 
normal conditions apply*)
if dynamic array is a Container type, size() / length() 
will do. if not process the nodes.
 
Is This Answer Correct ?    0 Yes 0 No
Murali
 
 
 
  Re: How can you quickly find the number of elements stored in a a) static array b) dynamic array ?
Answer
# 3
a) sizeof(array)/sizeof(element)
b) you cant (well, you can, eg. by using realloc, counting
from 0 up, and checking the result etc. but this is absurd),
its best to keep track somehow how many elements are there
in the array, but the BEST solution is...do NOT use dynamic
arrays at all, use std containers instead like vector.
 
Is This Answer Correct ?    1 Yes 0 No
Jaroosh
 

 
 
 
Other C++ General Interview Questions
 
  Question Asked @ Answers
 
How to write a program such that it will delete itself after exectution?  1
class basex { int x; public: void setx(int y) {x=y;} }; class derived : basex {}; What is the access level for the member function "setx" in the class "derived" above? a) private b) local c) global d) public e) protected Quark1
How many lines of code you have written for a single program? BoA1
What is Namespace? Samsung1
What are Binay tress and B trees? Diff between them? CTS3
whats the size of class EXP on 32 bit processor? class EXP { char c1; char c2; int i1; int i2; char *ptr; static int mem; }; Huawei4
Give 2 examples of a code optimization?  1
What are the different types of polymorphism?  2
Write the program for fibonacci in c++?  3
Write a program that read 2o numbers in and array and output the second largest number. Can anybody help??  2
What is the output of printf("%d")? HCL25
string somestring ; Which of the following choices will convert a standard C++ string object "somestring" to a C string? a) Copy.somestring () ; b) somestring.c_str () c) &somestring [1] d) std::cstring (somestring) e) (char *) somestring Quark1
What is the difference between a copy constructor and an overloaded assignment operator? Microsoft3
What is the use of static functions? Symphony6
Can we declare destructor as static? Explain?  2
Write a function which takes a character array as input and reverses it in place. Lehman-Brothers2
how can u create a doubly linked list with out using pointers?  1
What is Name Decoration? Lucent2
class Foo { public: Foo(int i) { } }; class Bar : virtual Foo { public: Bar() { } }; Bar b; Referring to the above code, when the object 'b' is defined, a compiler error will occur. What action fixes the compiler error? a) Adding a virtual destructor to the class Bar b) Adding a constructor to Bar which takes an int parameter c) Adding "Foo()" to the Bar constructor d) Adding a copy constructor to the class Foo e) Adding "Foo(0)" to the Bar::Bar initializer list Quark1
How do I open binary files?  1
 
For more C++ General Interview Questions Click Here 
 
 
 
 
 
   
Copyright Policy  |  Terms of Service  |  Help  |  Site Map 1  |  Articles  |  Site Map  |   Site Map  |  Contact Us interview questions urls   External Links 
   
Copyright © 2007  ALLInterview.com.  All Rights Reserved.

ALLInterview.com   ::  Forum9.com   ::  KalAajKal.com