GeeksforGeeks

Add Interview/written questions to Interview Corner!!
Register  |  Login

In C and C++, comma (,) can be used in two contexts:

Read More »

Predict the output of following C programs.

Read More »

Following are the differences between malloc() and new().

Read More »

Predict the output of below C++ programs.

Read More »

In C++, a static member function of a class cannot be virtual. For example, below program gives compilation error.

Read More »

Consider the below C/C++ program.

Read More »

Enumeration constants (enum values) are always of type int in C, whereas they are distinct types in C++ and may have size different from that of int.

Read More »

Predict the output of below C programs.

Read More »

Calling an undeclared function is poor style in C and illegal in C++. So is passing arguments to a function using a declaration that doesn’t list argument types:

Read More »

Write a C/C++ program that accepts a number from the user and prints “Even” if the entered number is even and prints “Odd” if the number is odd. Your are not allowed to use any comparison (==, < , >..etc) or conditional (if, else, switch, ternary operator,..etc) statement.

Read More »

In C++, compiler by default creates default constructor for every class. But, if we define our own parametrized constructor, then compiler doesn’t create the default constructor and default constructor may not exist in the class.

Read More »

Predict the output of below C programs.

Read More »

In C++, Reference variables are safer than pointers because reference variables must be initialized and they cannot be changed to refer to something else once they are initialized. But there are exceptions where we can have invalid references.

Read More »

Write a program to add one to a given number. You are not allowed to use operators like ‘+’, ‘-’, ‘*’, ‘/’, ‘++’, ‘–’ …etc.

Read More »

In C, we cannot access a global variable if we have a local variable with same name, but it is possible in C++ using scope resolution operator (::).

Read More »

The number of structurally different Binary Trees with n nodes is Catalan number Cn = (2n)!/(n+1)!*n!

Read More »

Given a integer x, write a function that multiplies x with 3.5 and returns the integer result. You are not allowed to use %, /, *.

Read More »

Don’t write a copy constructor if shallow copies are ok: In C++, If an object has no pointers to dynamically allocated memory, a shallow copy is probably sufficient. Therefore the default copy constructor, default assignment operator, and default destructor are ok and you don’t need to write your own.
Source: http://www.fredosaurus.com/notes-cpp/oop-condestructors/copyconstructors.html

Read More »

exit()

void exit ( int status );

exit() terminates the process normally.

Read More »

In C, it might not be possible to have function names on left side of an expression, but it’s possible in C++.

Read More »