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

276 Views
In this tutorial, we will be discussing a program to print an inverse pyramid character pattern.For this we will be provided with the number of rows containing in the inverted pyramid triangle. Our task is to print the alphabets in the given number of rows to develop the shape of an inverse pyramid.Example Live Demo#include using namespace std; //printing the inverse pyramid pattern void inv_pyramid(int n){ int i, j, num, gap; for (i = n; i >= 1; i--) { for (gap = n - 1; gap >= i; gap--) { cout

358 Views
Suppose we have a curve like y = x(A - x), we have to find the tangent at a given point (x, y) on that curve. Here A is an integer number, x and y are also integers.To solve this, we have the check that the given point is on the curve or not, if so, then find the differentiation of that curve, so it will be −$$\frac{\text{d}y}{\text{d}x}=A-2x$$Then put x and y into the dy/dx, then find the tangent using this equation −$$Y-y=-\lgroup\frac{\text{d}y}{\text{d}x}\rgroup*\lgroup X-x \rgroup$$Example Live Demo#include using namespace std; void getTangent(int A, int x, int y) { int differentiation ... Read More

247 Views
Consider we have an array A with n elements. We have to find the total sum of the sum of all the subsets of the array. So if the array is like A = [5, 6, 8], then it will be like −SubsetSum5566885, 6116, 8145, 8135, 6, 819Total Sum76As the array has n elements, then we have a 2n number of subsets (including empty). If we observe it clearly, then we can find that each element occurs 2n-1 timesExample Live Demo#include #include using namespace std; int totalSum(int arr[], int n) { int res = 0; for (int i = ... Read More

1K+ Views
In this tutorial, we will be discussing a program to print all the numbers divisible by 3 and 5 less than the given number.For this we will be given with a number say N. Our task is to print all the numbers less than N which are divisible by both 3 and 5.Example Live Demo#include using namespace std; //printing the numbers divisible by 3 and 5 void print_div(int N){ for (int num = 0; num < N; num++){ if (num % 3 == 0 && num % 5 == 0) cout

531 Views
Suppose, we have a number n, our task is to find the sum of digits in then!. Consider n = 5, then n! = 120. So the result will be 3.To solve this problem, we will create a vector to store factorial digits and initialize it with 1. Then multiply 1 to n one by one to the vector. Now sum all the elements in the vector and return the sumExample Live Demo#include #include using namespace std; void vectorMultiply(vector &v, int x) { int carry = 0, res; int size = v.size(); for (int i = 0 ; ... Read More

3K+ Views
In this tutorial, we will be discussing a program to print all the substring of a given string.For this we will be given with a string or an array of characters. Our task is to print all the substrings of that particular string.Example Live Demo#include using namespace std; //printing all the substrings void print_substr(char str[], int n){ for (int len = 1; len

141 Views
Suppose we have an array of n elements called A. We have to print the remainder after multiply all the numbers divided by n. Suppose A = [100, 10, 5, 25, 35, 14], and n = 11. The output is 9. So the value of 100 * 10 * 5 * 25 * 35 * 14 mod 11 = 9.First, we have to take the remainder of each number, then multiply the remainder with the current result. After multiplication, again take the remainder to avoid overflow.Example Live Demo#include #include using namespace std; int getRemainder(int a[], int size, int n) { int mul = 1; for(int i = 0; i

483 Views
In this tutorial, we will be discussing a program to print all palindromes in a given range.For this we will be given the mathematical range in which the palindromes are to be found. Our task is to find all the palindromes in that range and print it back.Example Live Demo#include using namespace std; //checking if the number is a palindrome int is_palin(int n){ int rev = 0; for (int i = n; i > 0; i /= 10) rev = rev*10 + i%10; return (n==rev); } void countPal(int min, int max){ for (int i = min; i

874 Views
In this tutorial, we will be discussing a program to print a given rectangular pattern.For this we will be given with the height and the breath of the rectangle. Our task is to print the rectangle with the given dimensions using the “@” character.Example Live Demo#include using namespace std; void print_rec(int h, int w){ for (int i=0; i

149 Views
Suppose we have a curve like y = x(A - x), we have to find the normal at a given point (x, y) on that curve. Here A is an integer number, x and y are also integers.To solve this, we have the check that the given point is on the curve or not, if so, then find the differentiation of that curve, so it will be −$$\frac{\text{d}y}{\text{d}x}=A-2x$$Then put x and y into the dy/dx, then find the normal using this equation −$$Y-y=-\lgroup\frac{\text{d}x}{\text{d}y}\rgroup*\lgroup X-x \rgroup$$Example Live Demo#include using namespace std; void getNormal(int A, int x, int y) { int differentiation ... Read More