Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
C++ Articles - Page 583 of 719
419 Views
Here we will see some basic differences between C++, Java and the Python. At first we will see the C++ and Java differences, then the Java and Python differences.TopicC++JavaMemory ManagementIt uses pointers, structures, unions and referencesIt does not support pointers. It supports references. It also supports Threads, interfacesLibrariesLow level functional librariesWide range of library, with various functionalitiesMultiple InheritanceSupports multiple inheritance using normal classesSupports multiple inheritance with only interfaces (pure abstract classes)Operating OverloadingOperator overloading is supportedDoes not support operator overloadingProgram HandlingFunctions and variables can reside outside of the classesFunctions, variables can only be there inside classes or packagesPortabilityCode is dependent on ... Read More
1K+ Views
The program takes a string and removes the spaces in it. This is useful when we want to save the space of our The following sample shows how it is done with an explanation.Input: Hello World Output: HelloWorldExplanationTo remove or delete spaces from the string or sentence, you have to ask the user to enter a string. Now start checking for spaces. If space will be found, then start placing the next character from the space to the back until the last character and continue to check for the next space to remove all the spaces present in the stringExample#include ... Read More
9K+ Views
What is Linear Search? Linear search is a sequential searching technique in which we start at one end of the list or array and look at each element until the target element is found. It is the simplest searching algorithm, with O(n) time complexity. Example Scenario let's see the following example scenario: Input: arr = {5, 4, 3, 8, 10}, K = 3; Output: 3 found at index 2; Input: arr = {1, 2, 3, 4, 5}, K = 7; Output: Not Found; How Linear Search Work? Following are the steps to search an element in array or ... Read More
2K+ Views
In this article, we will implement a C++ program to find whether a number is a power of two. So, you are given a positive integer n; the task is to find if the given number is a power of 2 or not. Let's see some of the numbers that represent the power of two. 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048 ... Example Scenario Let's see the following example scenario: Input: 4 Output: yes Explanation: 22 = 4 Input: 16 Output: yes Explanation: 24 = 16 Input: 5 Output: no Explanation: ... Read More
521 Views
What is Cycle Sort? Cycle sort is an in-place, unstable sorting algorithm. It is a comparison sort that is theoretically optimal in terms of the total number of writes to the original array, unlike any other in-place sorting algorithm. A sorting algorithm is in-place sorting in which the sorted items occupy the same place as the original one. Key Points of Cycle Sort Following are the key points: It is optimal in terms of number of memory writes. It minimize the number of memory write to sort (Each value is either written zero times, if ... Read More
443 Views
We are given a string with both vowels and consonants. Our task is to rearrange it so that vowels and consonants appear alternately, while keeping their original order within their groups. This rearrangement is only possible if the number of vowels and consonants is equal, or their difference is exactly one. If multiple valid arrangements are possible, we return the one that is lexicographically smaller. Let's understand this with a few example scenarios. Scenario 1 Input: "objective" Output: "bojecitev" Explanation: Vowels = [o, e, i, e], Consonants = [b, j, c, t, v] Consonants are more by 1 -> valid ... Read More
442 Views
In this article, we implement a C++ program to find the number that occurs an odd number of times in an array, using different approaches. We are given an array containing multiple elements, and our task is to identify the number that appears an odd number of times. For example, consider the array: [1, 2, 1, 3, 3, 2, 2]. In this case, the number 2 appears 3 times, which is odd. Example Scenarios Let's look at a few example scenarios to understand the problem: Input: arr[] = {5, 7, 8, 8, 5, 8, 8, 7, 7} ... Read More
317 Views
There are many types of series in mathematics which can be solved easily in C programming. This program is to find the sum of following of series in C program.Tn = n2 - (n-1)2Find the sum of all of the terms of series as Sn mod (109 + 7) and, Sn = T1 + T2 + T3 + T4 + ...... + TnInput: 229137999 Output: 218194447ExplanationTn can be expressed as 2n-1 to get itAs we know ,=> Tn = n2 - (n-1)2 =>Tn = n2 - (1 + n2 - 2n) =>Tn = n2 - 1 - n2 + 2n ... Read More
5K+ Views
"static const"“static const” is basically a combination of static(a storage specifier) and const(a type qualifier).The static determines the lifetime and visibility/accessibility of the variable. This means if a variable is declared as a static variable, it will remain in the memory the whole time when the program is running, while the normal or auto variables are destroyed when the function (where the variable was defined) is over.The const is a type qualifier. A type qualifier is used to express additional info about a value through type system. When a variable is initialized using the const type qualifier, it will not ... Read More
2K+ Views
Delete is an operator that is used to Deallocate storage space of Variable.This pointer is a kind of pointer that can be accessed but only inside nonstatic member function and it points to the address of the object which has called the member function.This pointer holds the address of the current object, in simple words, you can say that this pointer points to the current object of the classWhenever we call a member function through its object, compiler secretly passes the address of calling that object as the first parameter in member function as this pointer.Generally, delete operator should not ... Read More