| Other C++ General Interview Questions |
| |
| Question | Asked @ | Answers |
| |
| 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
| Quark | 1 |
| What happens if an exception is throws from an, object's
constructor and object's destructor? | Wipro | 1 |
| Is there any difference between dlearations int* x and int
*x? If so tell me the difference? | Lason | 13 |
| What is the difference between = and == in C? | Intel | 8 |
| What is difference between initialization and assignment? | HP | 4 |
| Is there something that we can do in C and not in C++? | Patni | 5 |
| wrong statement about c++
a)code removably
b)encapsulation of data and code
c)program easy maintenance
d)program runs faster | | 8 |
| Explain about profiling? | | 1 |
| what is difference between static and non-static variables | | 4 |
| const char *
char * const
What is the differnce between the above two? | TCS | 7 |
| what is pulse code modulation?
| Wipro | 1 |
| What is "strstream" ? | Huawei | 1 |
| 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 |
| 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 |
| How to implement flags? | Symphony | 1 |
| How to write a program such that it will delete itself after
exectution? | | 1 |
| Write the program form Armstrong no in c++? | | 4 |
| What is the Difference between "printf" and "sprintf"? | iSoft | 2 |
| 1)#include <iostream.h>
int main()
{
int *a, *savea, i;
savea = a = (int *) malloc(4 * sizeof(int));
for (i=0; i<4; i++) *a++ = 10 * i;
for (i=0; i<4; i++) {
printf("%d\n", *savea);
savea += sizeof(int);
}
return 0;
}
2)#include <iostream.h>
int main()
{
int *a, *savea, i;
savea = a = (int *) malloc(4 * sizeof(int));
for (i=0; i<4; i++) *a++ = 10 * i;
for (i=0; i<4; i++) {
printf("%d\n", *savea);
savea ++;
}
return 0;
}
The output of this two programs will be different why?
| | 2 |
| What compiler was used?
| Intel | 3 |
| |
| For more C++ General Interview Questions Click Here |