Posts

Showing posts from February, 2024

Euronet interview questions

Some questions were from test4geeks  void GetSomeVariable(int **i) {    if(*i == NULL)    {       *i = new int;    }   **i = 20;   } int main() {    int someValue = 10;    GetSomeVariable(&someValue);    cout << someValue <<endl;        int *ptr = nullptr;    GetSomeVariable(&ptr);    cout << *ptr <<endl; } How to make the code compilable without changing GetSomeVariable? Solution: Use Function overloading or Type traits #include <iostream> #include <type_traits> void g(int*) { std::cout << 'L'; } void g(int**) { std::cout << 'R'; } template<typename T> void f(T t) {     if (std::is_same_v<T, int>) { std::cout << 1; }      if (std::is_same_v<T, int*>) { std::cout << 2; }      if (std::is_same_v<T, int**>) { std::cout <...

Euronet Objective/Coding Test

Euronet test --> Follow Java point MCQs (https://www.javatpoint.com/cpp-mcq-part-2#) Same questions found in https://mcqsets.com/downloads/download-c-mcq-questions-pdf/ Coding question 1 int main() {   vector<string> str;   str.push_back("Camel");   str.push_back("Horse");   str.push_back("Goat");      for(auto i= str.rbegin(); i != str.rend(); i++)   {      cout << *i <<std::endl; swap(str[0], *i);   }   cout << str[2] <<std::endl; } Coding question 2 number N is given as input , such that 1< = N <= 100, Find Number X such that X is divisible by N and sum of digits of X is equal to N (hint: X != N) Coding question 3 int main() {   std::ios::sync_with_stdio(false);   vector<int> v{2,3,4,2};      for(auto i: v)   {      i--;   }   for(const auto &i: v)   {      cout << i-1 <<std::en...

C/C++ Syllabus to follow

Order arrangement in terms of frequency/no. of times question asked by interviewer --------------------------- Smart pointers and types such as unique_ptr, weak_ptr, auto_ptr and shared_ptr and difference between them (https://aticleworld.com/unique-pointer-in-cpp/) ,  moving ownership , typecasting of smart pointers and <memory> Thread api(std::thread) in C++  --> #include <thread>,  --> write a std::thread program Concurrency and thread synchronization mechanism like Locks , semaphores such as lock_gaurd, mutex, unique_lock, scoped_lock, producer-consumer, condition variables etc, algorithm.h functions such as reverse(), rotate() , count() etc. OOPs questions like type of constructors/destructors like pure virtual constructor, copy constructor, explicit constructor, virtual constructor, private constructor, typecasting constructor, constness of this, move constructor(move semantics), private destructor etc. Design pattern such as singleton will always ...

GlobalLogic Interview

 Toplevel traversal in a BST Class with parent virtual function defined (program) Virtual destructor copy constructor, copy constructor why do we give reference Polymorphism Frequency of characters in "globallogic" If we declare a constructor as private, can we create an object ? Ans: we can't create object on stack but we can create on heap using new  Even or odd using Thread coding question #include <thread> #include <iostream> using namespace std; void even_func(int n) {     if(n%2 == 0)     {         cout << "Number is even" <<endl;     }      } void odd_func(int n) {     if(n%2 != 0)     {         cout << "Number is odd" <<endl;     }      } int main() {      for(int i=0; i< 100; i++)      {         thread th1(even_func, i);         thre...

KPIT Interview question

// superclass cashwidhawal, 2 derived class savingaccount and currentaccount, user can withdraw 10k from saving accoun, if more than that throw you are not eligible // if user is withdraw from current account you are not authorized #include <iostream> using namespace std; const int CASH_LIMIT = 50000; class Cashwithdrawal {     protected:      double value;     public:              virtual void func(double amount) = 0;       virtual void get() = 0;      }; class SavingAccount: public Cashwithdrawal {     public:     SavingAccount(double value)     {         if(value >= CASH_LIMIT)         {             value = CASH_LIMIT;  // cash limit         }     }     void get()     {         cout << value <...