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

257 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

86 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

143 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

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

796 Views
Given with an array of natural numbers and the task is to calculate the mean absolute deviation and for that we must require the knowledge of mean, variance and standard deviation.There are steps that need to be followed for calculating the mean absolute deviationCalculate the meanCalculate absolute deviationAdd all the calculated deviationsApply the formulaInput arr[] = { 34, 21, 56, 76, 45, 11}Output mean absolute deviation is : 18.5Input arr[] = {10, 15, 15, 17, 18, 21}Output mean absolute mean absolute deviation is : 2.66used in the given program is as followsInput the elements of an arrayCalculate the mean of an arrayCalculate deviation using ... Read More

1K+ Views
Given with an array of natural numbers and the task is to calculate the harmonic mean of given numbers and print it.What is harmonic mean?Harmonic mean means the reciprocal of the arithmetic mean by their reciprocals.$$Harmonic\: Mean=\frac{n}{\frac{1}{a}+\frac{1}{b}+\frac{1}{c}+...}$$Where, n is the total number of elements given and a, b, c, .. are the actual elements in an array.Steps to calculate the harmonic mean are −Do the reciprocal of the elementsAdd all the reciprocated elements togetherNow divide the total number of elements in an array by the sum of reciprocated elementsInput arr[] = {2.0, 3.4, 5.3, 2.1}Output Harmonic mean is: 2.74163Input arr[] = {13.5, 14.5, ... Read More

745 Views
In this article, We implement a C++ program to print sum of series like 13 + 23 + 33 + 43 + .......+ n3 till the nth term. Given an integer n, calculate the sum of the cubes of the first n natural integers. So, we have to cube of 'n' natural integers and sum the results. Example Scenario Let's understand the following example scenario: Input: n = 4 Output: 100 Explanation: 13 + 23 + 23 + 43 Another example scenario: Input: n = 5 Output: 225 Explanation: 13 + 23 + 23 + 43 + 43 ... Read More

437 Views
Given an array arr[n] with n number of integers and another integer k, the task is to find the product all the elements of arr[] which are divisible by k.To solve the problem we have to iterate every element of the array and find whether it is completely divisible by the number k and then product all the elements and store it into a variable. Like we have an array arr[] = {1, 2, 3, 4, 5, 6 } and assuming we have k = 2 so the numbers in the array which are divisible by 2 are 2, 4, ... Read More

254 Views
Given an array arr[n] of n number of integers, the task is to find the product of all composite numbers in an array.Composite numbers are the whole numbers which are made by multiplying 2 other whole numbers. For example 6 is a composite number which can be made by multiplying 2 and 3 which are whole numbers. Also we can say they are not prime.Input arr[] = {1, 2, 4, 5, 6, 7}Output 24Explanation − the composite numbers in the array are 4 and 6 and their product is 24.Input arr[] = {10, 2, 4, 5, 6, 11}Output 240Explanation − the composite numbers in ... Read More

373 Views
Given an array arr[n] of n number of integers, the task is to find the product of all pairwise consecutive elements.Consecutive elements in an array arr[] are, if we are at ith element, i.e. arr[i] then its consecutive element will be either arr[i+1] or arr[i-1], so the product will be arr[i] * arr[i+1] or arr[i] * arr[i-1].Input arr[] = {1, 2, 3, 4}Output 2, 6, 12Explanation Splitting into pairs {1, 2}, {2, 3}, {3, 4} Their results will be 1*2 = 2, 2*3 = 6, 3*4 = 12Input arr[] = {9, 5, 1, 2, 6, 10}Output 45, 5, 2, 12, 60Explanation Splitting into pairs {9, 5}, ... Read More