Server Side Programming Articles

Page 2082 of 2109

Add N digits to A such that it is divisible by B after each addition?

sudhir sharma
sudhir sharma
Updated on 16-Aug-2019 197 Views

Given a, b and n. And we have to consider the following conditions and find the optimal solution to add n digits to a such that it is divisible by b after every iteration.Add a digit to a in such a way that after adding it, a is divisible by b.Print the smallest value of a possible after n iterations of step1.Print fail if the operation fails.check divisibility after every digit addition.Inputa=5 b=4 n=4Output52000ExplanationThe first digit to be added from 0 to 9, if none of the digits make a divisible by b then the answer is -1 which means the if n digits are ...

Read More

C++ program to read file word by word?

Arnab Chakraborty
Arnab Chakraborty
Updated on 13-Aug-2019 5K+ Views

In this section we will see how we can read file content word by word using C++. The task is very simple. we have to use the file input stream to read file contents. The file stream will open the file by using file name, then using FileStream, load each word and store it into a variable called word. Then print each word one by one.Algorithmread_word_by_word(filename)begin    file = open file using filename    while file has new word, do       print the word into the console    done endFile Content (test_file.txt)This is a test file. There are ...

Read More

C++ Programming Internals?

sudhir sharma
sudhir sharma
Updated on 09-Aug-2019 695 Views

C++ Internals means how the working of C++ compiler compiling the .cpp code and giving us the output. C++ is a popular programming language mostly used for writing system software. It is an extension of the C programming language. C is a compiled language. The C++ compiler compiles C++ code to an object or executable file is generated. The executable or the binary files contains machine executable instructions and some metadata of the machine instructions.A typical way of compiling a C++ program is to run the compiler on C++ code. The compiler will generate machine instructions which are set of ...

Read More

Area of a triangle inscribed in a rectangle which is inscribed in an ellipse?

sudhir sharma
sudhir sharma
Updated on 09-Aug-2019 415 Views

For understanding this complex problem, let's do it in two parts. First we will find the dimensions of the rectangle and based on that we can find the area of a triangle inscribed in it.Using the equation of ellipse and differential calculus, mathematical formula for the area of a rectangle is,  area = 2ab, where 2a = major axis and 2b = minor axis.The largest triangle that can be inscribed in the rectangle, should stand on the same base & has height raising between the same parallel sides of the rectangle.The area of largest triangle inscribed within the rectangle is ...

Read More

C++ Programming for Smallest K digit number divisible by X?

sudhir sharma
sudhir sharma
Updated on 08-Aug-2019 184 Views

Smallest K digit number that divisible by X is found using the formula by checking divisible by X. The formula works in the following way −Compute minimum K digit number [min] for example: 10/100/1000 etc.Now find if min is divisible by X. if yes, then this is the answer.If not, then min+X - ([min+X]%k) is the answer.Example#include #include using namespace std; int main() {    int X = 83;    int K = 5;    cout

Read More

Logic Gates in Python

Pavitra
Pavitra
Updated on 07-Aug-2019 4K+ Views

In this article, we will learn about Logic Gates in Python. Let’s look at each of the logic gates in Python in detail with some easy examples.All of us are quite familiar while implementing logic gates in the processing of electrical signals and are widely used in the electrical and electronics industry. They are used in the diodes and transistors so that we can design by proper alignment of these electronic devices. In this article we will learn about the implementation of some basic gates ‘and‘, ‘or‘ ,’not‘ , ‘nand‘ ,’nor‘ in Python 3.x or earlier.These gates can be implemented ...

Read More

C++ Program for Zeckendorf's Theorem?

Arnab Chakraborty
Arnab Chakraborty
Updated on 31-Jul-2019 360 Views

Here we will see how to check whether the given sum is found by adding some nonneighbouring Fibonacci numbers or not, if so, what are the numbers? For example if the give sum value is 10, this is sum of 8 and 2. Both 8 and 2 are Fibonacci terms and they are not adjacent. Let us see the algorithm to get the idea.AlgorithmnonNeighbourFibo(sum)Begin    while sum > 0, do       fibo := greatest Fibonacci term but not greater than sum       print fibo       sum := sum - fibo    done EndExample#include using ...

Read More

C++ Internals?

Arnab Chakraborty
Arnab Chakraborty
Updated on 31-Jul-2019 337 Views

Here we will see the Class internals. Before that we will see Default constructors, which are related to internals. The default constructor is one constructor (defined by user or compiler) that does not take any argument. Now the question comes, why the default constructor is used?If the default constructor is not given, the compiler will implicitly declare default constructor. Default constructors are used to initialize some class internals. It will not affect the data member of the class. The compiler inserts default constructor in some different situations. Suppose a class is derived from another class with default constructor, or one ...

Read More

What is NaN in C++?

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

The NaN is the abbreviation of Not a Number. It indicates undefined or non-representable floating point elements. One example of NaN is square root of some negative number, or result of 0/0.Example#include #include using namespace std; int main() {    cout >> "Square root of -5: " >> sqrt(-5) >> endl; }OutputSquare root of -5: nan

Read More

C++ Program to Implement Caesar Cypher

Anvi Jain
Anvi Jain
Updated on 30-Jul-2019 29K+ Views

It is a mono-alphabetic cipher wherein each letter of the plaintext is substituted by another letter to form the ciphertext. It is a simplest form of substitution cipher scheme.This cryptosystem is generally referred to as the Shift Cipher. The concept is to replace each alphabet by another alphabet which is ‘shifted’ by some fixed number between 0 and 25.For this type of scheme, both sender and receiver agree on a ‘secret shift number’ for shifting the alphabet. This number which is between 0 and 25 becomes the key of encryption.The name ‘Caesar Cipher’ is occasionally used to describe the Shift ...

Read More
Showing 20811–20820 of 21,090 articles
Advertisements