Keywords in C

A token is the smallest element of a program that is meaningful to the compiler. Tokens can be classified as follows: Keywords Identifiers Constants Strings Special Symbols Operators Keywords Keywords are already defined by Compiler that cannot be used as Variable Name, so keywords are also called as reserved words. The basic instructions are built up using a… Read More »

Identifier in C

A token is the smallest element of a program that is meaningful to the compiler. Tokens can be classified as follows: Keywords Identifiers Constants Strings Special Symbols Operators Identifiers Identifiers are names for entities in a C program, such as variables, arrays, functions, structures, unions and labels. An identifier can be composed only of uppercase, lowercase letters, underscore… Read More »

Comments in C/C++

A comment is text that the compiler ignores but that is useful for programmers. Comments are normally used to annotate code for future reference. Comments are statements that are not executed by the compiler and interpreter. The compiler treats them as white space. It makes a program more readable and error finding become easier. One important part of… Read More »

Choosing a Sorting Algorithm in Practice

There are many fundamental and advanced sorting algorithms. All sorting algorithms are problem-specific, which means they work well on some specific problem but do not work well for all the problems. All sorting algorithms apply to specific kinds of problems. Some sorting algorithms apply to a small number of elements, some are suitable for floating point numbers, some… Read More »

Merge Sort

Merge sort is a sorting technique based on the divide and conquer technique. Recursively: split the list in half, sort each half, then merge the sorted halves together. Algorithm : MergeSort(A, p, r): if p > r return q = (p+r)/2 mergeSort(A, p, q) mergeSort(A, q+1, r) merge(A, p, q, r) Example : 30 64 26 46 109… Read More »

Bubble Sort

Bubble Sort is the simplest sorting algorithm that works by repeatedly swapping the adjacent elements if they are in wrong order. It examines all pairs of adjacent elements, swapping them when they are out of order. Algorithm : for i in 0 .. n-2 for j in i .. n-1 if (a[j] > a[j+1]) swap(a[j], a[j+1]) We need… Read More »

Insertion Sort

Insertion sort is a simple sorting algorithm that works similar to the way you sort playing cards in your hands. For the 2nd, 3rd, 4th, etc. element: slide backwards into proper relative sorted position. This sort works on the principle of inserting an element at a particular position, hence the name Insertion Sort. Algorithm : for i in… Read More »

Selection Sort

In Selection Sort algorithm, First, find the smallest element and swap it with the first. Sort the rest of the list the same way. Algorithm : for i in 0 .. n-2 small := i for j in i+1 .. n-1 if (a[j] < a[small]) small := j swap(a[i], a[small]) Example : 30 64 26 46 109 21… Read More »

Comparisons between C++ and C#

1. C++ Programming Language : C++, as we all know is an extension to C language and was developed by Bjarne stroustrup at bell labs. C++ is an Object Oriented Programming language but is not purely Object Oriented. The language was updated 3 major times in 2011, 2014, and 2017 to C++11, C++14, and C++17. C++ can be… Read More »