Control structures and statements in C and C++

jojo September 20, 2012 8 Comments
Control structures form the basic entities of a “structured programming language“. We all know languages like C/C++ or Java are all structured programming languages. Control structures are used to alter the flow of execution of the program.  Why do we need to alter the program flow ? The reason is “decision making“! In life, we may be given with a set of option like doing “Electronics” or “Computer science”. We do make a decision by analyzing certain conditions (like...
read more

Quick Sorting algorithm with example code in C/C++/Java languages

jojo September 18, 2012 No Comments
We have seen 3 simple sorting algorithms already 1) Bubble Sorting 2) Selection Sorting and finally Insertion sorting. All these algorithms were so simple to understand and were easy to implement as a program in C/C++ or even Java. But at the same time all 3 of them were too inefficient.  Their execution time was of the order of n*n, where n is the number of elements to be sorted. In practice, these simple sorting algorithms are seldom used. ...
read more

Insertion sorting algorithm with example in C/C++/Java languages

jojo September 17, 2012 No Comments
So far we have seen 2 sorting algorithms:- 1) Bubble sorting and 2) Selection sorting. Now in this article, we are analyzing insertion sort algorithm with its example code suitable for C/C++/Java programming languages. I recommend you go through above articles of Bubble sorting and Selection sorting before reading further.  Insertion sorting algorithm sorts one element at a time. It begins by sorting the first 2 elements in order. In the next step, it takes the third element and compares it...
read more

Selection Sort in C/C++/Java programming languages

jojo September 17, 2012 No Comments
In the previous article, we have analysed Bubble sort algorithm and it’s implementation in C programs. In this article we are going to see another sorting algorithm, named, Selection sorting. Just like “Bubble sort”, selection sort is also considered as an inefficient sorting algorithm. If you are curious to know the reason for this, please read the article about Bubble sort carefully. The number of comparisons involved in an average bubble sort is 0.5*(n*n-n). Same is the index for...
read more

Difference between Procedure Oriented(POP) and Object Oriented Programming(OOP)

jojo September 14, 2012 7 Comments
We all know there exist 2 approaches to write a program – 1) Procedure oriented programming (POP) and 2) Object oriented programming (OOP). You can write a program in either way but there are notable differences between both approaches. These 2 approaches are the result of software development evolution over many decades. Since the invention of computer, many approaches and methods have been tried to write a program. It includes methods like a) Top-Down programming b) Bottom-Up programming c)...
read more

Bubble Sorting with example in C/C++/Java

jojo September 17, 2012 6 Comments
Bubble sorting is one of the simplest sorting algorithm that we can use to sort an array or a structure. Though it is so simple to implement in a C program, bubble sort is also considered as an inefficient sorting algorithm. Bubble sort comes handy in cases where the total number of elements to be sorted is so small (may be in the 100’s range). When the data size is large/huge bubble sort is seldom used in practical programming world. Let’s...
read more