The linear search procedure gives the method of finding whether an element is present in a set of elements (array) or not. The given element is compared with each element in the set one by one. The process is repeated until a perfect match is found. The array comprises of unsorted elements. [Read more…] about Array C++ Linear Search
Array C++ Insertion Sort
Insertion Sort is a sorting technique based on the idea of inserting a new element in a set of given elements so that the resulting elements are also in sorted order. Suppose a set of 4 elements A, A[l], A, A are to be sorted in ascending order. Initially sort Aand A[l] in ascending order. If A[l] is less than A, interchange their positions. Otherwise the positions of the elements remain the same. Next insert A in the appropriate position so that the resulting array A, A[l] and A remain sorted. The process is repeated in this manner. [Read more…] about Array C++ Insertion Sort
Array C++ Selection Sort
In this method, the smallest item in a given series of n elements is found and is placed in the first position. Then the smallest item from the remaining (n-l) elements is found and is placed in the second position and so on. This method requires (n-l) passes for arranging n elements. [Read more…] about Array C++ Selection Sort
Array C++ Bubble sort
In Bubble sort, two consecutive elements in a given list are compared and their positions in the given list (array) are interchanged in ascending or descending order as desired. Consider the following series of numbers, which are to be arranged in ascending or descending order. The series of numbers to be arranged are presented in the form of an array. The input array has the following form: [Read more…] about Array C++ Bubble sort
C++ Const Declaration for the size of an array
C++ Declaration of One Dimensional Arrays
Arrays are declared as follows: [Read more…] about C++ Declaration of One Dimensional Arrays
What is Continue statement in C++
Continue statement is used for continuing a loop when an unexpected condition occurs. Basically this statement helps in passing control to the beginning of the loop. [Read more…] about What is Continue statement in C++
Switch ….Case Statement
The statement tests the value of a variable against a list of integer or character constants. If the variable matches any of the constants, statements associated with that constant (case) are executed. If there is more than one statement following any case, the statements are enclosed in curly brackets. Value of the switch variable should be provided before the switch statement. [Read more…] about Switch ….Case Statement
Write C++ program finds the sum of the series using do..while loop.
Write C++ program exit() function
This function causes the program to terminate from any portion of the program and does not have any return value. It has only one argument whose value is returned to the operating system when the program is terminated. This function is included in the <stdlib.h> header file. Hence this header file must be included in the beginning of the program. [Read more…] about Write C++ program exit() function
Write C++ program finds the real root of an equation using Newton Raphson technique.
The desired accuracy is upto 6 decimal places. The formula for finding a real root of an equation f(x) = 0 is given by [Read more…] about Write C++ program finds the real root of an equation using Newton Raphson technique.
Write C++ program Illustrates if statement.
Write C++ program illustrates the hierarchy rule in a Boolean expression involving arithmetic, relational and logical operators
Write C++ program illustrates type cast.
Write C++ program illustrates automatic type conversion from char to int.
Write C++ program illustrates the difference between the pre increment operator and post increment operator.
Write C++ program illustrates the use of increment and decrement operators.
Arithmetic Assignment Operators in C++
C++ provides a short form when a variable is incremented, decremented etc. For example [Read more…] about Arithmetic Assignment Operators in C++
Write C++ program illustrates the hierarchy rule in an arithmetic expression involving arithmetic operators.
#define directive helps in creating constants which have no type information. This sets up an equivalence between an identifier and a text phrase. The syntax is #define v1 3.2
This should appear in the beginning of the program. It informs the compiler that the text V1 will be replaced by the text 3.2 in the entire program. However this directive is not used commonly.
Write C++ program to finds the area of the circle and the volume of the sphere with given radius.
Escape Sequences and Manipulators in c++
Commonly used escape sequences are \n, \t and \a. The escape sequences are enclosed in single quotes. \n is a new line character and helps in transferring control to the next line. If more than one line is to be skipped, \n is repeated as many times as the number of lines to be skipped. \n can also be combined with any other message string to be displayed. \t is used for giving tab and \a is used for giving a beep. [Read more…] about Escape Sequences and Manipulators in c++
Input Output Statements in c++
cin and cout are two predefined objects which represent standard input and output stream. The standard output stream represents the screen, while the standard input stream represents the keyboard. These objects are members of iostream class. Hence the header file <iostream.h> should be included in the beginning of all programs. [Read more…] about Input Output Statements in c++
Comments in C++
C++ supports comment format which is indicated by a II sign before the comment. In this case, the comment can proceed only till the end of current line. In case it is required to extend the comment beyond the current line, the comments should be preceded by the II symbol on subsequent lines also. [Read more…] about Comments in C++
const Member Functions c++
The const qualifier is used with the variables of basic data types to prevent them from being modified by the function. In a similar way, const qualifier can also be applied to member functions, member function arguments and the objects of a class. [Read more…] about const Member Functions c++
c++ – Returning object from function
A function can also return objects either by value or by reference. When an object is returned by value from a function, a temporary object is created within the function, which holds the return value. This value is further assigned to another object in the calling function. [Read more…] about c++ – Returning object from function
Objects as Function Arguments in c++
The objects of a class can be passed as arguments to member functions as well as nonmember functions either by value or by reference. When an object is passed by value, a copy of the actual object is created inside the function. This copy is destroyed when the function terminates. Moreover, any changes made to the copy of the object inside the function are not reflected in the actual object. On the other hand, in pass by reference, only a reference to that object (not the entire object) is passed to the function. Thus, the changes made to the object within the function are also reflected in the actual object. [Read more…] about Objects as Function Arguments in c++
Array of Objects in c++
Like array of other user-defined data types, an array of type class can also be created. The array of type class contains the objects of the class as its individual elements. Thus, an array of a class type is also known as an array of objects. An array of objects is declared in the same way as an array of any built-in data type. [Read more…] about Array of Objects in c++
Arrays as Class Members in C++
Arrays can be declared as the members of a class. The arrays can be declared as private, public or protected members of the class. [Read more…] about Arrays as Class Members in C++
Accessing Public and private members of C++ classes
The members of a class can be directly accessed inside the class using their names. However, accessing a member outside the class depends on its access specifier. The access specifier not only determines the part of the program where the member is accessible, but also how it is accessible in the program. [Read more…] about Accessing Public and private members of C++ classes