
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 33676 Articles for Programming

381 Views
In this article, we will learn different ways to pass arrays to functions in C++ and how to work with them effectively. Passing Arrays to Functions Here are list of approaches to pass arrays to functions in C++ that will be discussed in this article along with examples: As a Sized Array As an Unsized Array As a Pointer (Pass by Pointer) As a Reference (Pass by Reference) As a Sized Array This method passes an array to a ... Read More

3K+ Views
Dynamic arrays are a type of array that can grow or shrink their size as elements are added or removed. They are created using pointers and memory management functions such as new and delete. In this article, we will learn different ways to initialize a dynamic arrays in C++. Here is the list of approaches to initialize a dynamic array in C++: Using new and () Using new and {} Using Loop for Custom Initialization Initializing Dynamic Arrays Using new and () This ... Read More

8K+ Views
Sorting of an array refer to the process of arranging the elements of the array in ascending or descending order. In this article, we will learn how to use the std::sort function from the C++ STL library to sort an array. In this problem, you are given an array of integers, and you need to arrange the elements in ascending order using std::sort. For example: // Input array int arr[] = {5, 2, 9, 1, 5, 6}; // Output {1, 2, 5, 5, 6, 9} // Explanation: The array is sorted in ascending order. C++ ... Read More

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

854 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

470 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

217 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

329 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