- 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 7347 Articles for C++
![Sunidhi Bansal](https://www.tutorialspoint.com/assets/profiles/124656/profile/60_131452-1581053210.jpg)
497 Views
According to the problem we are given a string str, we must count all the substrings in the given string. Substring is a string which is a part of an already existing string whose size may be smaller than or equal to the existing string.Let's understand the problem and its solution with the help of examples.Input − str = "wxyz";Output − count of distinct substring is: 10Explanation − Distinct substrings counted are −wxyz, wxy, wx, w, xyz, xy, x, yz, y, z so their count is 10Input − str = "zzzz"Output − count of distinct substring is: 4Explanation − Distinct ... Read More
![Sunidhi Bansal](https://www.tutorialspoint.com/assets/profiles/124656/profile/60_131452-1581053210.jpg)
160 Views
We are given a positive integer N. The goal is to count the pairs of distinct non-negative positive integers that satisfy the inequality − x*x + y*y < N.We will start from x=0 to x2 lt; N and y=0 to y2 < N . If any x2 + y2 < N, increase count of pairs.Let us understand with examples −Input − n=4Output − distinct pairs= 4Explanation − pairs will be (0, 0), (1, 1), (0, 1), (1, 0). All these satisfy the inequality x2 + y2 < 4Input −n=2Output − distinct pairs= 3Explanation &minus pairs will be (0, 0), (0, ... Read More
![Sunidhi Bansal](https://www.tutorialspoint.com/assets/profiles/124656/profile/60_131452-1581053210.jpg)
871 Views
The abnormal behavior of C++ programs often leads to program crash. You may have encountered problems like Segmentation fault, Aborted, Floating point exception etc. Following are sample programs that may help you to understand the reasons for a C++ program crash.ExceptionsExceptions in C++ are responses of a program when it encounters an abnormal condition. The program crashes due to such exceptions if they are not handled properly using try-catch blocks. Following program crashes due to divide by zero exception −Example Live Demo#include int main(){ int num1=10; int num2=0; int quotient=num1/num2; printf(" Quotient is: %d", quotient); ... Read More
![Sunidhi Bansal](https://www.tutorialspoint.com/assets/profiles/124656/profile/60_131452-1581053210.jpg)
156 Views
Given an integer array arr[] with some elements, the task is to find the product of all the prime number of that numbers.Prime number are those number which are either divided by 1 or the number itself, or a prime number is a number which is not divisible by any other number except 1 and the number itself. Like 1, 2, 3, 5, 7, 11, etc.we have to find the solution for the given array −Input −arr[] = { 11, 20, 31, 4, 5, 6, 70 }Output − 1705Explanation − Prime numbers in array are − 11, 31, 5 their ... Read More
![Sunidhi Bansal](https://www.tutorialspoint.com/assets/profiles/124656/profile/60_131452-1581053210.jpg)
322 Views
Given a number n we have to find its all factors and find the product of those factors and return the result, i.e, the product of factors of a number. Factors of a number are those numbers which can divide the number completely including 1. Like factors of 6 are − 1, 2, 3, 6.Now according to the task we have to find the product all the factors of the number.Input − n = 18Output − 5832Explanation − 1 * 2 * 3 * 6 * 9 * 18 = 5832Input − n = 9Output − 27Explanation − 1 * 3 * 9 = 27Approach used below is as follows to solve the problem −Take the input num .Loop from i = 1 till i*i
![Sunidhi Bansal](https://www.tutorialspoint.com/assets/profiles/124656/profile/60_131452-1581053210.jpg)
278 Views
Given a number N, the task is to find the product of first N factorials modulo by 1000000007. . Factorial implies when we find the product of all the numbers below that number including that number and is denoted by ! (Exclamation sign), For example − 4! = 4x3x2x1 = 24.So, we have to find a product of n factorials and modulo by 1000000007..Constraint 1 ≤ N ≤ 1e6.Input n = 9Output 27Explanation 1! * 2! * 3! * 4! * 5! * 6! * 7! * 8! * 9! Mod (1e9 + 7) = 27Input n = 3Output 12Explanation 1! * 2! * 3! mod (1e9 ... Read More
![Sunidhi Bansal](https://www.tutorialspoint.com/assets/profiles/124656/profile/60_131452-1581053210.jpg)
184 Views
Given a string str, we have to print the given string str in ‘+’ pattern in the matrix. To form plus pattern in a matrix the matrix must be a square matrix. A square matrix is that matrix which has same number of rows and column.Like we have a string “Tutor” our task is to print the string horizontally and vertically intersecting each other from the center, and make the rest of the elements of the matrix as “x” like in the given figure −Input str[] = {“Point”}Output Input str[] = {“this”}Output Pattern not possibleApproach used below is as follows to solve the problemGet ... Read More
![Sunidhi Bansal](https://www.tutorialspoint.com/assets/profiles/124656/profile/60_131452-1581053210.jpg)
53 Views
Given with a value ‘n’ and the task is to generate the centered nonagonal number for n and centered nonagonal series till n and display the results.What is centered nonagonal number?Centered nonagonal number contains the nonagonal layers formed by the dots and one corresponding dot in the center.Given above is the figure of centered nonagonal number 𝑁2.It can be calculated using the formula −$$Nc(n)=\frac{(3n-2)(3n-1)}{2}$$Input number: 20Output centered nonagonal number : 1711Input number: 10Output centered nonagonal series : 1 10 28 55 91 136 190 253 325 406AlgorithmStart Step 1→ declare function to calculate centered nonagonal number int calculate_number(int num) return ... Read More
![Sunidhi Bansal](https://www.tutorialspoint.com/assets/profiles/124656/profile/60_131452-1581053210.jpg)
85 Views
Given with a value ‘n’ and the task is to generate the centered Icosahedral number for n and centered Icosahedral series till n and display the results.What is centered Icosahedral number?Centered Icosahedral number is a centered number used for representing an icosahedrons(it is a polyhedron figure with 20 faces).The first few centered icosahedral number series till n = 1000 are −1, 13, 55, 147, 309, 561, 923Centered Icosahedral number can be calculated using the formula −$$(2n+1)\times\frac{5n^{2}+5n+3}{3}$$Input number: 20Output Centered Icosahedral Number is : 28741Input number: 12Output Centered Icosahedral Number is : 6525AlgorithmStart Step 1→ declare function to calculate centered iscosahedral number int calculate(int ... Read More
![Sunidhi Bansal](https://www.tutorialspoint.com/assets/profiles/124656/profile/60_131452-1581053210.jpg)
12K+ Views
Given with an array of an unsorted array and the task is to calculate the mean and median of an unsorted array.For calculating the meanMean is calculated for finding out the average. We can use the given formula to find out the meanMean = (sum of all the elements of an array) / (total number of elementsFor calculating the medianIf an array is sorted, median is the middle element of an array in case of odd number of elements in an array and when number of elements in an array is even than it will be an average of two ... Read More