- 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++
885 Views
Rabin-Miller Primality Test is used to check if a given Number is Prime or not. It is similar to the format primality and the Solovay-Stressen test. this test first was discovered by Russian Mathematician M. M. Artjuhov.AlgorithmBegin ll mulmod(ll a, ll b, ll m) ll x = 0, y = a mod m while (b > 0) if (b mod 2 == 1) compute x = (x + y) mod m y = (y * 2) mod m b = b/ 2 ... Read More
262 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.
107 Views
The is a header file. This file includes all standard library. Sometimes in some coding contests, when we have to save time while solving, then using this header file is helpful.In software engineering approach we should reduce the minimize the include. Using this header file, it will include lots of files, sometimes that may not be required in the program. So it may increase the compile time and program size.Some of the big disadvantages of this header file is listed belowThis is not a standard header file of GNU C++ library. So some compiler may fail to compiler ... Read More
288 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
114 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
215 Views
In this post you can get some details where you can buy and view free drafts of some current and past C/C++ standards.C DocumentsC11:198 CHF (https://www.iso.org/standard/57853.html)Publicly at (http://www.open-std.org/JTC1/SC22/WG14/www/docs/n1570.pdf)Wikipedia Link (https://en.wikipedia.org/wiki/C11_(C_standard_revision))C99:Cannot Purchase (https://www.iso.org/standard/29237.html)Publicly at (http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1256.pdf)Wikipedia Link (https://en.wikipedia.org/wiki/C99)C90, C89, ANSI C, Standard CWikipedia Page: (https://en.wikipedia.org/wiki/ANSI_C)C++ DocumentsC++14:198 CHF (https://www.iso.org/standard/64029.html)Based On (https://www.iso.org/standard/29237.html)Wikipedia Link (https://en.wikipedia.org/wiki/ANSI_C)C++11:Cannot Purchase (https://www.iso.org/standard/50372.html)Publicly at (http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2011/n3242.pdf)Wikipedia Link (https://en.wikipedia.org/wiki/C%2B%2B11)C++03Wikipedia Page: (https://en.wikipedia.org/wiki/C%2B%2B03)C++89Wikipedia Page: (https://en.wikipedia.org/wiki/C%2B%2B)Read More
711 Views
In C++ the forward declaration lets the code following the declaration know that there is are classes with the name Person. This satisfies the compiler when it sees these names used. Later the linker will find the definition of the classes.Example CodeClass Person; void myFunc(Person p1) { // ... } Class Person { // Class definition here };So in this case when compiler encounters myFunc, it'll know that it is going to encounter this class somewhere down in the code. This can be used in cases where code using the class is placed/included before the code containing the class definition.
764 Views
This is C++ program to implement Segmented Sieve to Generate Prime Numbers Between Given Range. Segmented Sieve first uses Simple Sieve to find primes smaller than or equal to √(n). The idea of this algorithm is to divide the range [0 ... n-1] in different segments and compute primes in all segments one by one.AlgorithmBegin Create function to find all primes smaller than limit using simple sieve of eratosthenes. Finds all prime numbers in given range using segmented sieve A) Compute all primes smaller or equal to square root of high using simple sieve ... Read More
372 Views
This is C++ program to implement Sieve of Atkin to Generate Prime Numbers Between Given Range. The Sieve of Atkin is a modern algorithm for finding all prime numbers up to a specified integer.AlgorithmBegin Create a results list, filled with 2, 3, and 5. Initialize the sieve array with false values Mark siev[n] is true if one of the following is true: a) n = (4*x*x) + (y*y) has odd number of solutions n % 12 = 1 or n % 12 = 5. b) n = (3*x*x) + (y*y) has odd ... Read More
721 Views
The size of a struct type element taken by sizeof() is not always equal to the size of each individual member. Sometimes the compilers add some padding to avoid alignment issues. So the size may change. The padding is added when a structure member is followed by a member with a larger size or at the end of the structure. Different compiler has different types of alignment constraints. In C standard, the total alignment structure depends on the implementation.Case 1In this case the double z is 8-byte long, which is larger than x (4-byte). So another 4-byte padding is added. ... Read More