
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
Found 7197 Articles for C++

7K+ Views
Passing an array by reference is a method of passing arrays to functions in C++ that allows the function to access and modify the original array without creating a copy. In this article, we will learn how to pass arrays by reference, the benefits of this approach, and provide examples. Passing an Array by Reference In the pass by reference approach, the address location of the first element of the array is passed to user defined functions. So, technically, we are passing the same array to that function without creating a copy. The changes made to the array ... Read More

6K+ Views
In C/C++, we usually use the sizeof operator to find the size of an array. However, once an array is passed to a function, its size is lost. So, how can we find the size of an array without using sizeof? For example, consider this array: int arr[] = {1, 2, 3, 4, 5}; Without using sizeof, we can use a loop to count the number of elements in the array. In this article, we'll show you different methods to find the size of an array in C or C++ without using sizeof, with clear and simple examples. ... Read More

853 Views
A dynamic 2D array is an 2D array in which the size of array is determined during runtime and stored using pointers. In this article, we will learn how to create a dynamic 2D array inside a class in C++. First of all, let's understand the problem statement. In this problem, you need to create a class that contains a dynamic 2D array as its data member. The memory allocation and deallocation must be handled using constructor and destructor. For example: // Create a class with dynamic 2D array ClassMatrix m(3, 4); // Output Matrix of size ... Read More

4K+ Views
A string in C++ is a group of characters written inside double quotes like "Hello" and characters are the single letters or symbols in a string. Converting a string to a char array means putting each character into a simple list (array) of characters. In this article, we will show you how to convert a string to a character array in C++. For example, if we have the string "Hello@TP", converting it to a char array means storing each character 'H', 'e', 'l', 'l', 'o', '@', 'T', and 'P' separately in an array.How to Convert a String into a Character ... Read More

469 Views
Operator overloading has an important role in object oriented programming language features. Operator overloading is a type of compile time or static polymorphism.AlgorithmBegin Create a class Arr and declare size of array. Inside the class, initialize all the elements by using for loop. Print the all elements. End.Example Code Live Demo#include #include using namespace std; const int M = 7; class Arr { private: int A[M]; int size; public: Arr(int s, int v) { if(s>M) { cout

215 Views
A multidimensional array is an array with more than one dimension. It means that the array can grow in multiple directions, such as length, width, and height. In this article, we will learn how to print the dimensions of given multidimensional array in C++. First of all, let's understand the problem statement. You are given a multidimensional array as input, and you need to print its dimensions such as the number of rows, number of columns, and so on. For example: // Input multidimensional array int arr[3][4] = { {1, 2, 3, 4}, ... Read More

328 Views
The product of an array refers to the multiplication result of all the elements in the array. The STL library of C++ provides several built-in functions to quickly calculate product of an array. In this article, we will explain all those STL functions with examples. Consider the following input/output scenario to understand the concept of array product: // Input array int arr[] = {1, 2, 3, 4, 5}; // Output 120 Explanation: The product of the elements in the array is 1 * 2 * 3 * 4 * 5 = 120. Following ... Read More

3K+ Views
The pointers in C++ are used to store memory addresses of variables. We can perform pointer arithmetic such as incrementing or decrementing pointers to traverse through an arrays. In this article, we will learn how to using pointer arithmetic in C++ to traverse through an array and find sum of it. First of all, let's understand the problem statement. You are given an array of integers and you need to find the sum of all the elements in that array using pointer arithmetic. For example: // Input array int arr[] = {1, 2, 3, 4, 5}; ... Read More

224 Views
In multidimensional array, the array should have dimension more that 1. The following diagram shows the memory allocation strategy for a multidimensional array with dimension 3 x 3 x 3.This is a C++ program to initialize a multidimensional array.AlgorithmBegin Initialize the elements of a multidimensional array. Print the size of the array. Display the content of the array. EndExample#include using namespace std; int main() { int r, c; int a[][2] = {{3,1},{7,6}}; cout

223 Views
This is a C++ program return a local array from a function.AlgorithmBegin We can use dynamically allocated array to return a local array from function Array(). Print the elements of the array. EndExample Code Live Demo#include using namespace std; int* Array() { int* a = new int[100]; a[0] = 7; a[1] = 6; a[2] = 4; a[3] = 5; return a; } int main() { int* p = Array(); cout