Skip to content

Category Archives: C++

itoa function converts integer into null-terminated string. It can convert negative numbers too. The standard definition of itoa function is given below:-   C char* itoa(int… 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. One reason for passing… Read More
Write a program that prints “GeeksforGeeks” with empty main() function. You are not allowed to write anything in main(). C language One way of doing… Read More
A constructor is a special type of member function of a class that initializes objects of a class. In C++, Constructor is automatically called when… Read More
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. We can… Read More
C++ supports function overloading, i.e., there can be more than one function with the same name but, different parameters. How does the C++ compiler distinguish… 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, each… 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 the same purpose in both C++ and Java. There are some differences though. This post covers similarities and differences… Read More
We can print 1 to 100 without using loops and recursion using three approaches discussed below: 1) Template Metaprogramming: Templates in C++ allow non-datatypes also… Read More
Predict the output of following C++ programs. Question 1 #include <iostream> using namespace std;    template <int N> class A {    int arr[N]; public:    virtual… Read More
We have discussed assignment operator overloading for dynamically allocated resources here. In this article, we discussed that when we don’t write our own assignment operator,… Read More

Start Your Coding Journey Now!