Posts by HARI HARAN B

Author Biographical Info: Not available

How to sort an array in descending order in C++

By HARI HARAN B

Sorting a sequence is a problem of great importance in computer science and software development. This article describes the methods to sort both a normal array and the STL array c.... Read More

How to find index of largest element in an array C++

By HARI HARAN B

Finding the index of the largest element in an unsorted array is done through brute force search. If the array is sorted the task is trivial and the index is the length-1 if it’s.... Read More

How to swap the position of two array elements in C++

By HARI HARAN B

Swapping elements in an array is handy in many standard algorithms like bubble sort. In this article, we shall look at the basic principles of swapping and swapping positions in an.... Read More

How to generate random string in C++

By HARI HARAN B

Generating random strings will be helpful in many applications. As strings are arrays of characters and characters are stored as numbers the problem comes down to generating random.... Read More

How to create a dynamic array in C++

By HARI HARAN B

The normal (static ) arrays have their size initialized in compile time. Although, they are useful in some cases most of the time it is required to initialize arrays size in runtim.... Read More

The new[] operator in C++

By HARI HARAN B

The new[] operator is used to dynamically allocate a required amount of storage in the free store. The dynamically allocated memory has to be deleted properly and the delete operat.... Read More

How to create custom comparator for map in C++

By HARI HARAN B

The std::map sorts the elements based on the key value and this sorting is usually done in descending order for most fundamental datatypes. The key values are compared using the st.... Read More

How to get the current date and time in C++ in various formats

By HARI HARAN B

Obtaining the current date and time is crucial in many programs. The C++ STL provides the <chrono> library which can be used with <ctime> from c to get the current time.... Read More