| Other C++ General Interview Questions |
| |
| Question | Asked @ | Answers |
| |
| If P is the population on the first day of the year, B is
the birth rate, and D is the death rate, the estimated
population at the end of the year is given by the formula:
The population growth rate is given by the formula:
B – D
Write a program that prompts the user to enter the starting
population, birth and death rates, and n, the number of
years. The program should then calculate and print the
estimated population after n years. Your program must have
at least the following functions:
1. growthRate: This function takes its parameters the
birth and death rates, and it returns the population growth
rate.
2. estimatedPopulation: This function takes its
parameters the current population, population growth rate,
and n, the number of years. It returns the estimated
population after n years
Your program should not accept a negative birth rate,
negative death rate, or a population less than 2.
| | 1 |
| Difference between delete and delete[]? | TCS | 3 |
| class X
{
private:
int a;
protected:
X(){cout<<"X constructor was called"<<endl;}
~X(){cout<<"X destructor was called"<<endl}
};
Referring to the code above, which one of the following
statements regarding "X" is TRUE?
a) X is an abstract class.
b) Only subclasses of X may create X objects.
c) Instances of X cannot be created.
d) X objects can only be created using the default copy
constructor.
e) Only friends can create instances of X objects.
| Quark | 2 |
| What are the techniques you use for debugging? | Adtran | 1 |
| what is the order of initialization for data? | TCS | 4 |
| What is the output of:
String a1 = "Hello";
String a2 = "world!";
String* s1 = &a2;
String& s2 = a1;
s1 = &a1;
s2 = a2;
std::cout << *s1 << " " << s2 << std::endl; | Lehman-Brothers | 4 |
| What is the difference between "calloc" and "malloc"? | ADP | 5 |
| What issue do auto_ptr objects address? | | 1 |
| What are the advantages and disadvantages of using inline
and const? | TCS | 1 |
| Write any small program that will compile in "C" but not in
"C++"? | | 3 |
| What is design pattern? | Samsung | 2 |
| what is importance of data sturture in a programming
language? | L&T | 10 |
| Can we declare destructor as static? Explain? | | 2 |
| What is problem with Runtime type identification?
| | 1 |
| Give 2 examples of a code optimization? | | 1 |
| What are Binay tress and B trees? Diff between them? | CTS | 3 |
| template<class T, class X> class Obj {
T my_t;
X my_x;
public:
Obj(T t, X x) : my_t(t), my_x(x) { }
};
Referring to the sample code above, which one of the
following is a valid conversion operator for the type T?
a) T operator T () { return my_t; }
b) T operator(T) const { return my_t; }
c) operator(T) { return my_t; }
d) T operator T (const Obj &obj) { return obj.my_t; }
e) operator T () const { return my_t; }
| Quark | 1 |
| what is meaning of isa and hsa | | 1 |
| int f() {
int I = 12;
int &r = I;
r += r / 4;
int *p = &r;
*p += r;
return I;
}
Referring to the sample code above, what is the return value
of the function "f()"?
a) 12
b) 15
c) 24
d) 17
e) 30
| Quark | 2 |
| Can we have "Virtual Constructors"? | TCS | 5 |
| |
| For more C++ General Interview Questions Click Here |