Dynamic Memory Allocation in C++

Dynamic Memory Allocation in C++ In the C++ programming language, new() is a language construct that dynamically allocates memory from free store and initialises the memory using the constructor. new() attempts to allocate enough memory in free store for the new data. If successful, it initialises the memory and returns the address to the newly […]

Namespaces in C++

Namespaces in C++ Namespaces decide the problem of naming conflicts between different fragments of code. For example, you might be writing some code that has a function called calculate(). One day, you decide to start using a third-party library, which also has a calculate() function. The compiler has no way of knowing which version of […]

Arrays in C++ part 1

Arrays in C++ An array is a data structure which allows a collective name to be given to a group of elements which all have the same type. An individual element of an array is identified by its own unique index. An array is a fixed number of elements of the same type stored sequentially in memory. Therefore, an […]

File Input Output C++

File Input Output C++ In  C/C++ programming language, Input/output library refers to a family of class templates and supporting functions in the C++ Standard Library that implement stream-based input/output capabilities. Some Useful Functions that might come very handy in I/O. I/O libraries ifstream OpenFile(char *filename, int mode); You should know the the file name which is stored […]

Insertion Sort Algorithm

Insertion Sort Algorithm C++ Insertion sort algorithm removes an element from the sorting list, and placing it into the correct position in the already sorted part of the list, until no input elements left. The insertion sort algorithm complexity depends on the input list. If the list is already sorted we have best case, which […]

How to convert lowercase letters to uppercase in C++?

Convert lowercase letters to uppercase in C++ The function int toupper ( int c ) convert lowercase letter to uppercase. It’s standard build in function in cstring library. Converts c to its lowercase equivalent if c is an uppercase letter and has a lowercase equivalent. If no such conversion is possible, the value returned is c unchanged. Example usage of toupper […]

If and else statements in C++

Control Flow Statements in C++ If-then else If the value of expression is nonzero, statement 1 is executed. If the optional else is present, statement 2 is executed if the value of expression is zero.expression must be of arithmetic or pointer type, or it must be of a class type that defines an unambiguous conversion to an arithmetic or pointer type. Program Output Share->

Bubble Sort Algorithm

Bubble Sort Algorithm C++ Bubble Sort Algorithm  works by repeatedly stepping through the list to be sorted, comparing each pair of adjacent items and swapping them if they are in the wrong order. The pass through the list is repeated until no swaps are needed, which indicates that the list is sorted. Bubble sort has […]

Calculate adjacent differences elements C++

Calculate adjacent differences elements C++ The adjacent_difference() calculate differences between range of elements [first,last) in a container. The result is a sequence in which the first element is corresponding to the first element of the sequence being processed, and the remaining elements are corresponding to the calculated differences between adjacent elements. Syntax: adjacent_difference (first, last, […]

Compile C code gcc Linux

Compile C/C++ code GCC Linux GCC stands for GNU Compiler Collection. GCC is an integrated collection of compilers for several major programming languages, which as of this writing are C, C++, Objective-C, Java, FORTRAN, and Ada. The GNU compilers all generate machine code, not higher-level language code which is then translated via another compiler. How […]

Proudly powered by WordPress   Premium Style Theme by www.gopiplus.com