C++ interview questions part 35

C++ interview questions part 35

Take as many assements as you can to improve your validate your skill rating

Total Questions: 20

1. How to print the value of the i variable inside namespace B? namespace A{ int var = 10; namespace B{ int i = 15; } }

Correct Answer is : 40

2. What will be the output of following C++ code? #include #include using namespace std; namespace My_old_school_and_college_friends_number { long int f1 = 9999999999; long int f2 = 1111111111; } namespace contacts = My_old_school_and_college_friends_number; int main(){   cout<
Correct Answer is : 34


3. What will be the output of the following C++ code? Content of header file h1.h ------------------------------------------------ h1.h #include using namespace std; namespace A{ int func(int a){ cout<<"using namespace A"; return 2*a; } } ------------------------------------------------   Content of header file h2.h ------------------------------------------------   h2.h #include using namespace std; namespace B{ float func(float a){ cout<<"using namespace B"; return 2*a; } } ------------------------------------------------   Content of program.cpp ------------------------------------------------   #include #include #include "h1.h" #include "h2.h" using namespace std; using namespace A; using namespace B; int main(int argc, char const *argv[]) { /* code */ int a = 10; float b = 10.0; cout<
Correct Answer is : 3 or 4


4. What can be the possible output? Content of header file h1.h ------------------------------------------------ h1.h #include using namespace std; namespace A{ int func(int a){ cout<<"using namespace A"; return 2*a; } } ------------------------------------------------   Content of header file h2.h ------------------------------------------------   h2.h #include using namespace std; namespace B{ float func(float a){ cout<<"using namespace B"; return 2*a; } } ------------------------------------------------   Content of program.cpp ------------------------------------------------ #include #include #include "h1.h" #include "h2.h" using namespace std; using namespace A; using namespace B; int main(int argc, char const *argv[]) { /* code */ int a = 10; float b = 10.0; cout<
Correct Answer is : Difference


5. Given the below header files. Content of h1.h ------------------------------------------------ h1.h #include using namespace std; int func(int a){ cout<<"Multiplied by 2"; return 2*a; } ------------------------------------------------   Content of h2.h ------------------------------------------------ h2.h #include using namespace std; int func(int a){ cout<<"divided by 2"; return a/2; } ------------------------------------------------ What changes you can do in the header files to avoid the redefinition that compiler will give when both the header files are included in the same program keeping the declaration of both the functions same?

Correct Answer is : An object that generates uniformly distributed numbers

6. How does a sequence of objects are accessed in c++?

Correct Answer is : Objects that converts a sequence into a sequence having specific random variable distribution

7. How many parameters are present in mismatch method in non-sequence modifying algorithm?

Correct Answer is : Uses initial seed based algorithm to generate random numbers

8. What will happen in ‘all_of’ method if the range is empty?

Correct Answer is : 3

9. To what kind of elements does non-modifying sequence algorithm can be applied?

Correct Answer is : A true random number generator

10. Pick out the incorrect method in non-modifying sequence algorithm?

Correct Answer is : Lagged fibonacci generator algorithm

11. To which type does the numeric limits are suitable?

Correct Answer is : Random number engine that generates pseudo-random numbers

12. Where does the member should be defined if it is used in the program?

Correct Answer is : Class template that adopts a pseudo-random number generator engine to produce numbers with a given numbers of bits

13. What will the max function in the numeric limit will return for type float?

Correct Answer is : 3

14. Which header file is used for the numeric limits in C++?

Correct Answer is : -3

15. Pick out the incorrect static function member in numeric limits.

Correct Answer is : integer:10character:x

16. Where does the object is created?

Correct Answer is : 1

17. How to access the object in the class?

Correct Answer is : Exceptions are not suitable for critical points in code

18. Which of these following members are not accessed by using direct member access operator?

Correct Answer is : Exceptions are used when postconditions of a function can be satisfied

19. Pick out the other definition of objects.

Correct Answer is : iostream is a standard header and iostream.h is a non-standard header

20. How many objects can present in a single class?

Correct Answer is : declarations

Similar Interview Questions

    Search for latest jobs

    Icon
    Icon