GeeksforGeeks

A computer science portal for geeks

Browsing the topic C/C++ Puzzles

In C++, following function declarations cannot be overloaded.

Read More »

Given a program on fork() system call.

Read More »

In C++, what is the difference between exit(0) and return 0 ?

Read More »

Given below a small piece of code from an open source project,

Read More »

In C, given a string variable str, which of the following two should be preferred to print it to stdout?

Read More »

At compile time, the compiler exports each global symbol to the assembler as either strong or weak, and the assembler encodes this information implicitly in the symbol table of the relocatable object file. Functions and initialized global variables get strong symbols.

Read More »

How to swap two variables? The question may look silly, neither geeky. See the following piece of code to swap two integers (XOR swapping),

Read More »

Difficulty Level: Rookie Consider the following C++ program.

Read More »

In C++, like other functions, assignement operator function is inherited in derived class.

Read More »

1) static member functions do not have this pointer. For example following program fails in compilation with error “`this’ is unavailable for static member functions “

Read More »

In C/C++, getc() returns EOF when end of file is reached. getc() also returns EOF when it fails. So, only comparing the value returned by getc() with EOF is not sufficient to check for actual end of file.

Read More »

What do we mean by data alignment, structure packing and padding? Predict the output of following program.

Read More »

A nested class is a class which is declared in another enclosing class. A nested class is a member and as such has the same access rights as any other member

Read More »

Declare “a function with argument of int* which returns pointer to an array of 4 integer pointers”. Read reference post.

Read More »

C supports variable numbers of arguments. But there is no language provided way for finding out total number of arguments passed.

Read More »

We know that the elements in a structure will be stored in sequential order of their declaration.

Read More »

What will be the output of the following program?

Read More »

Function templates and static variables: Each instantiation of function template has its own copy of local static variables.

Read More »

What will be the output of following program?

Read More »

The process of removing function entries from function call stack at run time is called Stack Unwinding. Stack Unwinding is generally related to Exception Handling. In C++, when an exception occurs, the function call stack is linearly searched for the exception handler, and all the entries before the function with exception handler are removed from [...]

Read More »

What will be the output of the following C program?

Read More »

Predict the output of following C++ program.

Read More »

A class declaration can contain static object of self type, it can also have pointer to self type, but it cannot have a non-static object of self type.

Read More »

Ideally delete operator should not be used for this pointer. However, if used, then following points must be considered.

Read More »

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

Read More »