
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++

14K+ Views
In this article, we'll show you how to write a C++ program to access elements of an array using pointer. A pointer is a variable that holds the memory address of another variable, allowing us to reference it directly. In other words, pointers point to a memory location and obtaining the value stored at that location is called dereferencing the pointer. By using pointers, we can access and work with array elements through their memory addresses. Let's look at a simple example: Input: An array: [10, 20, 30, 40, 50] // We'll use a pointer to access ... Read More

3K+ Views
In this article, we will show you how to find the length of a string in C++. A string in C++ is a sequence of characters, such as letters, numbers, symbols, or anything enclosed in double quotes (e.g., "Hello"). To find the length of a string, we count all the characters, including spaces, but we don't count the null terminator('\0'). For example, let's look at the following string in C++. // Example 1 Input: "Learning C++ with tutorialspoint is fun!" To find the length, we count every character, including spaces. So, the total length is 40. Output: 40 ... Read More

14K+ Views
A matrix is a rectangular array of numbers arranged in rows and columns. To find the transpose of a matrix, we arrange the rows of the original matrix as columns in a new matrix. Similarly, the columns can also be arranged as rows. An example of the transpose of a matrix is as follows: Finding Transpose of a Matrix To find the transpose of a matrix in C++, we use multidimensional arrays to store matrix values in rows and columns. Then, we swap the rows and columns to get the transpose. Below are the steps we followed: ... Read More

5K+ Views
A matrix is a rectangular array of numbers that is arranged in the form of rows and columns.An example of a matrix is as follows.A 3*3 matrix has 3 rows and 3 columns as shown below −8 6 3 7 1 9 5 1 9A program that multiplies two matrices using multidimensional arrays is as follows.Example Live Demo#include using namespace std; int main() { int product[10][10], r1=2, c1=3, r2=3, c2=3, i, j, k; int a[2][3] = { {2, 4, 1} , {2, 3, 9} }; int b[3][3] = { {1, 2, 3} , {3, 6, 1} , {2, 9, 7} }; if (c1 != r2) { cout

2K+ Views
A matrix is a rectangular array of numbers arranged in rows and columns. To add two matrices, they must be the same size. We add each number in the first matrix to the number in the same position in the second matrix to get a new matrix An example of the addition of two matrices is as follow: Adding Two Matrices Using Multidimensional Arrays To add two matrices in C++, we use multidimensional arrays. These arrays help us store matrix values in rows and columns, just like a real matrix. Then, we add the two matrices stored ... Read More

8K+ Views
An array stores multiple values of the same data type. To find the average, we add all the numbers and then divide the total by how many numbers there are. In this article, we'll show you how to write a C++ program to calculate the average of numbers using an array. For example, if we have the numbers 40, 80, 10, 75, and 25, their total is 230, and the average is 230 / 5 = 46. Approaches for Calculating Average Using Arrays In C++, we can calculate the average of numbers in an array in two main ... Read More

5K+ Views
Calculating a power means multiplying the base by itself as many times as the exponent indicates. In this article, we'll show you how to write a C++ program to calculate the power of a number using recursion. For example, 2 raised to the power of 3 (2^3) means multiplying 2 by itself 3 times: 2 * 2 * 2, which gives 8. Using Recursion to Calculate Power To calculate the power of a number, we use recursion, where a function keeps calling itself with smaller values until it reaches a stopping point. Here are the steps we ... Read More

3K+ Views
Natural numbers are positive numbers starting from 1, such as 1, 2, 3, and so on. Here, we will take a positive number n as input and and then will find the sum of all natural numbers from 1 up to n using recursion using C++ program. Example Input: n = 5 The sum of the first 5 natural numbers is: 1 + 2 + 3 + 4 + 5 = 15 Output: 15 Input: n = 8 The sum of the first 8 natural numbers is: 1 + 2 + 3 + 4 + 5 + 6 ... Read More

2K+ Views
A prime number is a number greater than 1 that has no divisors other than 1 and itself. For example, 2, 3, 5, 7, and 11 are prime numbers. In this article, we'll show you how to write a C++ program to display prime numbers between two intervals using function. For example, given the interval from 0 to 50, we want to print all the prime numbers within this interval. Input: Starting interval: 0 Ending interval: 50 Output: Prime numbers in the interval [0, 50] are: 2 3 5 7 11 13 17 19 23 29 31 ... Read More

2K+ Views
In this article, we will show you how to write C++ programs to create different pyramids and patterns. You can create many kinds of patterns using stars, numbers, and alphabets. Below is the list of patterns we will cover in this article- Simple Pyramid Pattern in C++ Flipped Simple Pyramid Pattern in C++ Inverted Pyramid Pattern in C++ Flipped Inverted Pyramid Pattern in C++ Triangle Pattern in C++ Inverted Triangle Pattern in C++ ... Read More