Server Side Programming Articles

Page 2083 of 2109

C++ Program to Encode a Message Using Playfair Cipher

Smita Kapse
Smita Kapse
Updated on 30-Jul-2019 6K+ Views

In this scheme, pairs of letters are encrypted, instead of single letters as in the case of simple substitution cipher.In playfair cipher, initially a key table is created. The key table is a 5×5 grid of alphabets that acts as the key for encrypting the plaintext. Each of the 25 alphabets must be unique and one letter of the alphabet (usually J) is omitted from the table as we need only 25 alphabets instead of 26. If the plaintext contains J, then it is replaced by I.The sender and the receiver deicide on a particular key, say ‘tutorials’. In a ...

Read More

C++ Program to Decode a Message Encoded Using Playfair Cipher

Nishtha Thakur
Nishtha Thakur
Updated on 30-Jul-2019 569 Views

In this scheme, pairs of letters are encrypted, instead of single letters as in the case of simple substitution cipher.In playfair cipher, initially a key table is created. The key table is a 5×5 grid of alphabets that acts as the key for encrypting the plaintext. Each of the 25 alphabets must be unique and one letter of the alphabet (usually J) is omitted from the table as we need only 25 alphabets instead of 26. If the plaintext contains J, then it is replaced by I.The sender and the receiver deicide on a particular key, say ‘tutorials’. In a ...

Read More

C++ Program to Perform Sorting Using B-Tree

Chandu yadav
Chandu yadav
Updated on 30-Jul-2019 526 Views

Here we will see how to get the sorted sequence using B-Tree. The B-tree is n-ary tree. To get the sorted sequences, we can create a B-tree, then add the numbers into it. Here the B-tree can hold maximum 5 nodes. If number of nodes increases, split the node and form new level. As the nodes are holding few number of elements like 5 (at most), we are using Bubble sorting techniques to sort them. as the number of elements is very low, then it will not affect too much on its performance.After traversing the tree, we will get all ...

Read More

C++ Program to Solve a Matching Problem for a Given Specific Case

Smita Kapse
Smita Kapse
Updated on 30-Jul-2019 534 Views

This is a C++ Program to solve a matching problem for a Given Specific Case. Here, N men and N women are given, each person has ranked all members of the opposite gender in order of preference, marry the men and women together such that there are no two people of opposite gender who would both rather have each other than their current partners. All the marriages are “stable”, if there are no such people exists.AlgorithmsBegin    function WomenPrefersMenOverMen1():    A) Check if women prefer men over her current engagement men1    B) If men1 comes before men in list ...

Read More

What is the difference between size_t and int in C++?

karthikeya Boyini
karthikeya Boyini
Updated on 30-Jul-2019 5K+ Views

Here we will see what are the differences between size_t and int in C++. If we consider the standard, both are integers of size 16 bits.On a typical 64-bit system, the size_t will be 64-bit, but unsigned int will be 32 bit. So we cannot use them interchangeably.One standard recommendation is that the size_t be at most as big as an unsigned long. So you may think that we can use unsigned long in the place of size_t, but unsigned long on 64-bit system, if the OS ins Windows, will be of 32-bits, but size_t will be of 64-bits.

Read More

Generate random numbers using C++11 random library

Samual Sam
Samual Sam
Updated on 30-Jul-2019 2K+ Views

In C++11, we can get the random library to generate random numbers. Here we have used random_device once to seed the random number generator object called mt. This random_device is slower than the mt19937, but we do not need to seed it. It requests for random data to the operating system.Example #include #include using namespace std; int main() {    random_device rd;    mt19937 mt(rd());    uniform_real_distribution dist(20.0, 22.0); //range is 20 to 22    for (int i=0; i> dist(mt) >> endl; }Output21.5311 21.7195 21.0961 21.9679 21.197 21.2989 20.6333 20.441 20.7124 20.2654 21.1877 20.4824 20.0575 20.9432 21.222 21.162 21.1029 20.2253 21.5669 20.3357

Read More

How does generic lambda work in C++14?

Samual Sam
Samual Sam
Updated on 30-Jul-2019 344 Views

In C++11, the lambda was introduced. Lambdas are basically a part of, that can be nested inside other function call statements. By combining lambda expressions with the auto keyword, they can be used later.In C++14, these lambda expressions are improved. Here we can get the generalized or generic lambda. For example, if we want to create a lambda, that can add integers, add numbers, also concatenate strings, then we have to use this generalized lambda.Syntax of the lambda expression is looking like this −[](auto x, auto y) { return x + y; }Let us see one example to get the ...

Read More

How to launch a program using C++ program?

Samual Sam
Samual Sam
Updated on 30-Jul-2019 3K+ Views

Here we will see how to start some third-party application like notepad or anything using C++ program. This program is very simple, we can use command prompt command to do this task.We will pass the application name inside the system() function. This will open it accordingly.Example#include using namespace std; int main() {    cout >> "Opening Nodepad.exe" >> endl;    system("notepad.exe"); }Output

Read More

Catch block and type conversion in C++

Smita Kapse
Smita Kapse
Updated on 30-Jul-2019 259 Views

In this section, we will see how to use the catch block for exception handling and the type conversion in C++.At first, let us see a code, and we will see what will be the output, and how they are generating.Example#include using namespace std; int main() {    try{       throw 'a';    }    catch(int a) {       cout

Read More

Rint(), rintf(), rintl() in C++

Nishtha Thakur
Nishtha Thakur
Updated on 30-Jul-2019 245 Views

Here we will see three functions. These functions are Rint(), rintf() and the rintl(). These functions are used to convert floating point values into rounded format.The rint() FunctionThis function is used for rounding floating point value to integer. The syntax is like below. If the result is outside of return type, the domain error may occur. When the argument is 0 or infinity, then it will return unmodifiedfloat rint(float argument) double rint(double argument) long double rint(long double argument)Example#include #include using namespace std; main() {    double a, b, x, y;    x = 53.26;    y = 53.86; ...

Read More
Showing 20821–20830 of 21,090 articles
Advertisements