- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- 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 7346 Articles for C++
![Samual Sam](https://www.tutorialspoint.com/assets/profiles/13514/profile/60_83486-1512649303.jpg)
4K+ 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
![karthikeya Boyini](https://www.tutorialspoint.com/assets/profiles/13518/profile/60_31598-1537784993.jpg)
2K+ 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 4*3 matrix has 4 rows and 3 columns as shown below −3 5 1 7 1 9 3 9 4 1 6 7A program that adds two matrices using multidimensional arrays is as follows.Example Live Demo#include using namespace std; int main() { int r=2, c=4, sum[2][4], i, j; int a[2][4] = {{1,5,9,4} , {3,2,8,3}}; int b[2][4] = {{6,3,8,2} , {1,5,2,9}}; cout
![Samual Sam](https://www.tutorialspoint.com/assets/profiles/13514/profile/60_83486-1512649303.jpg)
7K+ Views
Average of numbers is calculated by adding all the numbers and then dividing the sum by count of numbers available.An example of this is as follows.The numbers whose average is to be calculated are: 10, 5, 32, 4, 9 Sum of numbers = 60 Average of numbers = 60/5 = 12A program that calculates average of numbers using arrays is as follows.Example Live Demo#include using namespace std; int main() { int n, i; float sum = 0.0, avg; float num[] = {12, 76, 23, 9, 5}; n = sizeof(num) / sizeof(num[0]); for(i = 0; i < n; i++) sum += num[i]; avg = sum / n; cout
![karthikeya Boyini](https://www.tutorialspoint.com/assets/profiles/13518/profile/60_31598-1537784993.jpg)
4K+ Views
The power of a number can be calculated as x^y where x is the number and y is its power.For example.Let’s say, x = 2 and y = 10 x^y =1024 Here, x^y is 2^10A program to find the power using recursion is as follows.Example Live Demo#include using namespace std; int FindPower(int base, int power) { if (power == 0) return 1; else return (base * FindPower(base, power-1)); } int main() { int base = 3, power = 5; cout
![Samual Sam](https://www.tutorialspoint.com/assets/profiles/13514/profile/60_83486-1512649303.jpg)
2K+ Views
The natural numbers are the positive integers starting from 1.The sequence of natural numbers is −1, 2, 3, 4, 5, 6, 7, 8, 9, 10……The program to find the sum of first n natural numbers using recursion is as follows.Example Live Demo#include using namespace std; int sum(int n) { if(n == 0) return n; else return n + sum(n-1); } int main() { int n = 10; cout
![karthikeya Boyini](https://www.tutorialspoint.com/assets/profiles/13518/profile/60_31598-1537784993.jpg)
2K+ Views
A prime number is a whole number that is greater than one and the only factors of a prime number should be one and itself. Some of the first prime numbers are 2, 3, 5, 7, 11, 13 ,17 etc.There can be many prime numbers between two intervals. For example, the prime numbers between the intervals 5 and 20 are 5, 7, 11, 13, 17 and 19.The program to find and display the prime numbers between two intervals is given as follows.Example Live Demo#include using namespace std; void primeNumbers (int lbound, int ubound) { int flag, i; while (lbound
![Samual Sam](https://www.tutorialspoint.com/assets/profiles/13514/profile/60_83486-1512649303.jpg)
1K+ Views
There are many different pyramid patterns that can be created in C++. These are mostly created using nested for loops. Some of the pyramids that can be created are as follows.Basic Pyramid PatternThe code to create a basic pyramid is given as follows.Example Live Demo#include using namespace std; int main() { int n = 6, i, j; for (i=1; i
![Samual Sam](https://www.tutorialspoint.com/assets/profiles/13514/profile/60_83486-1512649303.jpg)
2K+ Views
An Armstrong Number is a number where the sum of the digits raised to the power of total number of digits is equal to the number.Some examples of Armstrong numbers are as follows −3 = 3^1 153 = 1^3 + 5^3 + 3^3 = 1 + 125 + 27 = 153 407 = 4^3 + 0^3 + 7^3 = 64 +0 + 343 = 407 1634 = 1^4 + 6^4 + 3^4 + 4^4 = 1 + 1296 + 81 + 256 = 1634A program that displays the Armstrong numbers between two intervals is as follows.Example Live Demo#include #include using namespace std; int main() { int lowerbound, upperbound, digitSum, temp, remainderNum, digitNum ; lowerbound = 100; upperbound = 500; cout
![karthikeya Boyini](https://www.tutorialspoint.com/assets/profiles/13518/profile/60_31598-1537784993.jpg)
890 Views
An Armstrong Number is a number where the sum of the digits raised to the power of total number of digits is equal to the number. Some examples of Armstrong numbers are as follows.3 = 3^1 153 = 1^3 + 5^3 + 3^3 = 1 + 125 + 27 = 153 371 = 3^3 + 7^3 + 1^3 = 27 + 343 + 1 = 371 407 = 4^3 + 0^3 + 7^3 = 64 +0 + 343 = 407A program that checks whether a number is an Armstrong number or not is as follows.Example Live Demo#include #include
![Samual Sam](https://www.tutorialspoint.com/assets/profiles/13514/profile/60_83486-1512649303.jpg)
398 Views
A prime number is a whole number that is greater than one and the only factors of a prime number should be one and itself. Some of the first prime numbers are 2, 3, 5, 7, 11, 13 ,17 etc.There can be many prime numbers between two intervals. For example, the prime numbers between the intervals 5 and 20 are −5, 7, 11, 13, 17 and 19.The program to find and display the prime numbers between two intervals is given as follows.Example Live Demo#include using namespace std; void PrimeNumbers (int lbound, int ubound) { int flag, i; while (lbound