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

1K+ Views
Schonhage-Strassen Algorithm is used to multiply two numbers. The SchonhageStrassen algorithm is an asymptotically fast multiplication algorithm for large integers. In practice the Schonhage-Strassen algorithm starts to outperform older methods like karatsuba and Toom-CooK for numbers beyond 2215 to 2217 (10, 000 to 40, 000 decimal) digits.AlgorithmBegin function noOfDigit( x) Declare a variable n and assign n = 0; while (x > 0) x = x /10 Increment n return n End Begin Algorithm for schonhageStrassenMultiplication: schonhageStrassenMultiplication(a, b, n, m) define an array linearConvolution[n + m ... Read More

2K+ Views
Booth's algorithm is a multiplication algorithm that multiplies two signed binary numbers in 2's complement notation. Booth used desk calculators that were faster at shifting than adding and created the algorithm to increase their speed. In this article, we have an array of multiplicand bits and an array of multiplier bits. Our task is to use Booth's algorithm to find the multiplication of these two binary numbers. Example of Booth's Algorithm In this example, we have used Booth's algorithm to calculate the multiplication of two signed binary numbers mathematically. Input: Multiplier(M): 01011 = 11 Multiplicand(Q): 01110 = 14 ... Read More

961 Views
Fermat's Little theorem states that if 'p' is a prime number and 'a' is an integer that is not divisible by p, then a^(p-1) ≡ 1 modulo p or a^(p-1) mod p = 1. We will use Fermat's Little theorem to test whether the given number is a prime number or not. In this article, we have a number num and a given number of iterations itr. Our task is to implement a primality test for the given number using Fermat's theorem in C++. Steps to Perform Fermat Primality Test The steps to perform Fermat's Primality test are as ... Read More

611 Views
The Sieve of Sundaram method is used to generate the prime number within the given range. In this method, first we mark the indices with prime number using the mathematical formula. Then, we use the unmarked indices to get the prime numbers within the given range. In this article, we have defined a range i.e. 'm = 30'. Our task is to generate prime numbers up to 'm' using the Sieve of Sundaram method in C++. Example Here is an example of generating prime numbers up to 10 using the Sieve of Sundaram method: Input: M = 10 Output: ... Read More

4K+ Views
The gcd refers to 'Greatest Common Divisor', i.e. greatest common number which can divide all the given numbers. The lcm refers to the 'Least Common Multiple' i.e. the lowest common multiple of all the numbers. To find the gcd and lcm of n numbers in C++, we can use various approaches like iterative approach, or built-in C++ functions. In this article, we are having 'n' number of elements, our task is to find the gcd and lcm of n number of elements using C++. Example Here is an example of GCD and LCM of 4 numbers: Input: Numbers = ... Read More

1K+ Views
Rabin-Miller algorithm is a probabilistic primality test algorithm that is used to checks if a given number is likely to be a prime number or not. It is similar to the Fermat's primality test and the Solovay-Stressen test. In this article, we have a number 'p'. Our task is to implement the Rabin-Miller algorithm to check if the given number is a prime number or not in C++. Example Here is an example of checking prime numbers using the Rabin-Miller algorithm: Input: p = 41 Output: 41 is a prime nnumber Here is the explanation of the ... Read More

361 Views
The difference between the two forms is in the location where the preprocessor searches for the file to be included.#include The preprocessor searches in an implementation-dependent manner, it searches directories pre-designated by the compiler. This method is usually used to include standard library header files.#include "filename"The preprocessor searches in the same directory as the file containing the directive. If this fails, then it starts behaving like the #include form. This method is usually used to include your own header files.

215 Views
The is a header file that includes all the standard C++ library. It is used during coding contests, as it helps in saving time while solving the problem since programmers do not have to remember all the header files. In the software engineering approach, we should reduce the use of this header file, as it includes lots of files, and sometimes that may not be required in the program. So it may increase the compile time. In this article, we are going to discuss why we should not use the header file ... Read More

420 Views
const_castcan be used to remove or add const to a variable. This can be useful if it is necessary to add/remove constness from a variable.static_castThis is used for the normal/ordinary type conversion. This is also the cast responsible for implicit type coercion and can also be called explicitly. You should use it in cases like converting float to int, char to int, etc.dynamic_castThis cast is used for handling polymorphism. You only need to use it when you're casting to a derived class. This is exclusively to be used in inheritance when you cast from base class to derived class.reinterpret_castThis is ... Read More

183 Views
Basically this kind of errors are originated from the linker in the compilation phase. The default behavior of a linker is to take the code from archive libraries when the current program needs it.To work properly the libraries must be present in order. We can say that it must be there in the form “caller before callees”. This problem can be solved by choosing non-default behavior using flags, but in this process the linking may take larger time. Otherwise it can be solved by ordering the libraries correctly. Loaders and tsort these two can help to rearrange and correct the ... Read More