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

2K+ Views
In this article, we will understand how to display all the prime numbers from 1 to N in Java. All possible positive numbers from 1 to infinity are called natural numbers. A number is a prime number if its only factors are 1 and itself and cannot be divided by any other number. 11 is a prime number. Its factors are 1 and 11 itself. Some examples of prime numbers are 2, 3, 5, 7, 11, 13, and so on. 2 is the only even prime number. All other prime numbers are odd numbers. Below is a demonstration of the ... Read More

1K+ Views
An armstrong number is a positive integer that is equal to the sum of its digits, each raised to the power of the total number of digits in the number. Our goal here is to check armstrong numbers in C++. In simple terms, for a number with n digits: abcd... = a^n + b^n + c^n + d^n + ... If this condition is satisfied, we can say the number is an armstrong number. Let's understand with examples: 153 is an Armstrong number because: 1^3 + 5^3 + 3^3 = 1 + 125 + 27 = 153 ... Read More

566 Views
A prime number is a number greater than 1 that has no divisors other than 1 and itself. For example, 2, 3, 5, 7, and 11 are prime numbers. In this article, we'll show you how to write a C++ program to display prime numbers between two intervals. ExampleFor example, given the interval from 0 to 50, we want to print all the prime numbers within this interval. Input: Starting interval: 0 Ending interval: 50 Output: Prime numbers in the interval [0, 50] are: 2 3 5 7 11 13 17 19 23 29 31 37 41 ... Read More

8K+ Views
In this article, we'll show you how to write a C++ program to find the largest element in an array. An array is a collection of values that share the same data type. Our task is to go through all the elements stored in the array and find the one with the highest value. For example, consider the following arrays: //Example 1 int arr[] = {11, 13, 21, 45, 8}; Here, the largest element is 45. //Example 2 int arr[] = {1, 9, 2, 5, 7}; In this case, the largest element is ... Read More

2K+ Views
In this article, we will learn how to convert a binary number to a decimal number and a decimal number to a binary number using C++. This means converting numbers like 5 or 10 into a format that uses only 0s and 1s, and also converting binary numbers back into decimal. Decimal number system has a base of 10 as it uses 10 digits from 0 to 9, while binary has a base of 2 as it uses only 0 and 1. Binary is used in computers because digital devices can only represent two states: on(1) and off(0). Example ... Read More

10K+ Views
In this article, we'll show you how to write a C++ program to find the Greatest Common Divisor(GCD) of two numbers using Recursion. The GCD of two numbers is the largest number that divides both of them without leaving a remainder. It is also known as the Greatest Common Factor (GCF). For example, the GCD of 36 and 60 is 12, because 12 is the largest number that divides both 36 and 60 without a remainder. Using Recursion to Find the GCD To find the GCD, we use recursion. In recursion, a function keeps calling itself with updated ... Read More

1K+ Views
In this article, we'll show you how to write a C++ program to calculate the factorial of a number using recursion . The factorial of a number is the result of multiplying all the positive numbers from 1 to that number. It is written as n! and is commonly used in mathematics and programming. Let's understand this with a few examples: //Example 1 Input: 5 The factorial of 5 is: 5 * 4 * 3 * 2 * 1 = 120 Output: 120 //Example 2 Input: 6 The factorial of 6 is: 6 * 5 * 4 * ... Read More

2K+ Views
In this article, we'll show you how to write a C++ program to create a simple calculator that can add, subtract, multiply, or divide using a switch statement. The calculator works by taking two numbers(operands) and an operator (+, -, *, /) from the user, and then it performs the chosen operation. Lets understand it better with an example: Suppose the user enters: a = 5 and b = 4 Then, based on the chosen operator: If the operator is +, the result is 5 + 4 = 9 If the operator is -, the result is 5 ... Read More

6K+ Views
In this article, we will show you how to check whether a number is prime by creating a function in C++. A prime number is a number greater than 1 that has no divisors other than 1 and itself. For example, 2, 3, 5, 7, and 11 are prime numbers because they have only two divisors (1 and themselves), whereas 4, 6, 8, and 9 are not prime. Using a Function to Check Prime Number To check if a number is prime, we define a function that performs the check and returns true if the number ... Read More

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