Given a floating point number, write a function to count set bits in its binary representation.
itoa function converts integer into null-terminated string. It can convert negative numbers too.
Consider the following program. Change the program so that the output of printf is always 10. It is not allowed to change main(). Only fun()… Read More »
The problem is to create a class such that the non-dynamic allocation of object causes compiler error. For example, create a class ‘Test’ with following… Read More »
When we create our own copy constructor, we pass an object by reference and we generally pass it as a const reference.
Write a program that prints “GeeksforGeeks” with empty main() function. You are not allowed to write anything in main().
In C++, compiler creates a default constructor if we don’t define our own constructor (See this).
Standard C library provides qsort() that can be used for sorting an array. As the name suggests, the function uses QuickSort algorithm to sort the… Read More »
Write a C program that doesn’t terminate when Ctrl+C is pressed. It prints a message “Cannot be terminated using Ctrl+c” and continues execution.
C++ supports function overloading, i.e., there can be more than one functions with same name and differences in parameters. How does C++ compiler distinguishes between… Read More »
To calculate time taken by a process, we can use clock() function which is available time.h. We can call the clock function at the beginning… Read More »
Write a program to Validate an IPv4 Address. According to Wikipedia, IPv4 addresses are canonically represented in dot-decimal notation, which consists of four decimal numbers,… Read More »
Given some text lines in one string, each line is separated by ‘\n’ character. Print the last ten lines. If number of lines is less… Read More »
Static keyword is used for almost same purpose in both C++ and Java. There are some differences though. This post covers similarities and differences of… Read More »
Following is a C++ program that prints 1 to 100 without loop and without recursion.