How to find position of a digit in a number in C programming?

This program will find out the position of a digit in a number. For example digit 4 is present in 41234253 at 4th and 8th positions from left.Logic is simple, we start with the number say 41234253 and do modulo operation with 10. We’ll get the last digit 3. If it matches the digit (4 … Continue reading “How to find position of a digit in a number in C programming?”

What is std::unique_ptr? How to Use std::unique_ptr?

0 0 0 0 1 0 The std::unique_ptr is basically a template smart pointer class. It is smart about cleaning up the allocated memory. Template class means this can work with different data types. We have to provide the actual pointer in time of constructing the object. In the desctuctor, the pointer is freed. Another thing … Continue reading “What is std::unique_ptr? How to Use std::unique_ptr?”

How to do Asynchronous Operation using boost::asio?

0 0 0 0 0 0 Boost::asio was initially designed for accomplishing time-consuming networking I/O (Input/Output) operations in asynchronous way. I/O operations over network usually takes some time to complete. If you call a function that does I/O operation over network, the calling thread will block until the I/O operation is complete. This is a … Continue reading “How to do Asynchronous Operation using boost::asio?”

History of Programming Languages

0 0 0 0 0 0 Programming languages are complex even today at least to many programmers like me. But once you know the history of programming languages, you’ll definitely change your mind. Machine Language You might already know the computers understand only two symbols, zero (0) and one (1). Everything in computer is represented … Continue reading “History of Programming Languages”

C Program to Find Second Largest Element in an Array

0 1 0 0 0 0 Here we’ll see the possible solutions of finding the second largest element in an array. By Sorting the Array: Easy solution that I can think of to find the second largest element in an array is to first sort the array and then pick the second or second last … Continue reading “C Program to Find Second Largest Element in an Array”

How to Implement Shell Sort in C Programming?

0 0 0 0 0 0 Shell Sort (aka shellsort) can be thought as an improvement over insertion sort. To understand shell sort, we have to recall how insertion sort works. In insertion sort at any moment, the whole array is sub-divided in two sections, one is sorted and another is not. One element is picked from the … Continue reading “How to Implement Shell Sort in C Programming?”

How to Implement Quick Sort in C?

0 0 0 0 0 0 Quick Sort is an efficient sorting algorithm developed by Tony Hoare in 1959. It is still a commonly used sorting algorithm in most practical cases. If implemented properly, it is two or three times faster than other efficient sorting algorithms like merge sort or heap sort. Here we’ll see … Continue reading “How to Implement Quick Sort in C?”

How to Implement Merge Sort in C?

0 0 0 0 0 0 Merge sort is efficient, general-purpose sorting algorithm. Unlike bubble sort or insertion sort, it is usable in most practical cases. Merge sort is divide and conquer algorithm. Here we’ll see how to implement merge sort in C programming language. We’ll also analyze its performance in various conditions. Merge Sort … Continue reading “How to Implement Merge Sort in C?”

How to Implement Bubble Sort in C Programming?

0 0 0 0 0 0 Bubble Sort is very popular sorting algorithm in computer programming. Its popularity is not for its performance but for its simplicity. In fact bubble sort is not suitable for most of the practical cases because of its inefficiency. But it very easy to understand and code compare to other sorting … Continue reading “How to Implement Bubble Sort in C Programming?”

How to Implement Insertion Sort in C Programming?

0 0 0 0 1 0 Insertion sort is one of the most popular sorting algorithms. Its popularity is not because of its performance but for its simplicity. Its performance is not as good as quicksort or shellsort for large number of inputs but it is very simple like bubble sort. It is often used for less … Continue reading “How to Implement Insertion Sort in C Programming?”