- 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++
![karthikeya Boyini](https://www.tutorialspoint.com/assets/profiles/13518/profile/60_31598-1537784993.jpg)
6K+ Views
An array contains multiple elements and the largest element in an array is the one that is greater than other elements.For example.51724In the above array, 7 is the largest element and it is at index 2.A program to find the largest element of an array is given as follows.Example Live Demo#include using namespace std; int main() { int a[] = {4, 9, 1, 3, 8}; int largest, i, pos; largest = a[0]; for(i=1; ilargest) { largest = a[i]; pos = i; } } cout
![Samual Sam](https://www.tutorialspoint.com/assets/profiles/13514/profile/60_83486-1512649303.jpg)
2K+ Views
In a computer system, the binary number is expressed in the binary numeral system while the decimal number is in the decimal numeral system. The binary number is in base 2 while the decimal number is in base 10.Examples of decimal numbers and their corresponding binary numbers are as follows −Decimal NumberBinary Number100101070011125110011610000A program that converts the binary numbers into decimal and the decimal numbers into binary is as follows.Example Live Demo#include using namespace std; void DecimalToBinary(int n) { int binaryNumber[100], num=n; int i = 0; while (n > 0) { binaryNumber[i] = n % 2; n = n / 2; i++; } cout
![karthikeya Boyini](https://www.tutorialspoint.com/assets/profiles/13518/profile/60_31598-1537784993.jpg)
8K+ Views
The Greatest Common Divisor (GCD) of two numbers is the largest number that divides both of them.For example: Let’s say we have following two numbers: 45 and 2763 = 7 * 3 * 3 42 = 7 * 3 * 2 So, the GCD of 63 and 42 is 21A program to find the GCD of two numbers using recursion is given as follows.Example Live Demo#include using namespace std; int gcd(int a, int b) { if (a == 0 || b == 0) return 0; else if (a == b) return a; else if (a > b) return gcd(a-b, b); else return gcd(a, b-a); } int main() { int a = 63, b = 42; cout
![Samual Sam](https://www.tutorialspoint.com/assets/profiles/13514/profile/60_83486-1512649303.jpg)
1K+ Views
Factorial of a non-negative integer n is the product of all the positive integers that are less than or equal to n.For example: The factorial of 7 is 5040.7! = 7 * 6 * 5 * 4 * 3 * 2 *1 7! = 5040Let us see the code to calculate the factorial of a number using recursion.Example Live Demo#include using namespace std; int fact(int n) { if ((n==0)||(n==1)) return 1; else return n*fact(n-1); } int main() { cout
![Samual Sam](https://www.tutorialspoint.com/assets/profiles/13514/profile/60_83486-1512649303.jpg)
5K+ 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 ,17A program to check if a number is prime or not using a function is as follows.Example Live Demo#include using namespace std; void isPrime(int n) { int i, flag = 0; for(i=2; i
![karthikeya Boyini](https://www.tutorialspoint.com/assets/profiles/13518/profile/60_31598-1537784993.jpg)
2K+ Views
A palindrome number remains the same if its digits are reversed i.e its value does not change. A palindrome number can also be called symmetric. For example: The numbers 12321, 1551, 11 etc are palindromes as they do not change even if their digits are reversed.A program that checks if a number is palindrome or not is as follows.Example Live Demo#include using namespace std; void palindrome(int num) { int rev=0,val; val = num; while(num > 0) { rev = rev * 10 + num % 10; num = num / 10; } if(val==rev) cout
![Samual Sam](https://www.tutorialspoint.com/assets/profiles/13514/profile/60_83486-1512649303.jpg)
2K+ Views
Multiplication of two numbers a and b yields their product. Value of a is added as many times as the value of b to get the product of a and b.For example.5 * 4 = 20 7 * 8 = 56 9 * 9 = 81Program to Multiply two Numbers using * OperatorA program to multiply two numbers using the * operator is given as follows −Example Live Demo#include using namespace std; int main() { int a = 6, b = 8; cout
![karthikeya Boyini](https://www.tutorialspoint.com/assets/profiles/13518/profile/60_31598-1537784993.jpg)
9K+ Views
There are 128 characters in the ASCII (American Standard Code for Information Interchange) table with values ranging from 0 to 127.Some of the ASCII values of different characters are as follows −CharacterASCII ValueA65a97Z90z122$36&38?63A program that finds the ASCII value of a character is given as follows −Example Live Demo#include using namespace std; void printASCII(char c) { int i = c; cout
![Samual Sam](https://www.tutorialspoint.com/assets/profiles/13514/profile/60_83486-1512649303.jpg)
2K+ Views
Operator overloading can be done with most of the built-in operators in C++. The overloaded operators are functions with the keyword operator followed by the operator symbol that is defined. The overloaded operators have a return type and a parameter list like any function.A program that subtracts complex numbers using operator overloading is as follows −Example Live Demo#include using namespace std; class ComplexNum { private: int real, imag; public: ComplexNum(int r = 0, int i =0) { real = r; imag = i; } ComplexNum operator - (ComplexNum const ... Read More