Found 7346 Articles for C++

Centered Heptagonal Number

Simran Kumari
Updated on 23-Aug-2023 09:50:57

94 Views

What do you understand by the term centered hepatgonal number? Let’s decode in this article. First of all, what is a heptagonal number? A heptagonal number is a figurate number representing the number of dots that can be arranged to form a regular heptagon (a seven−sided polygon). The formula for the nth heptagonal number is: n(5n−3)/2, where n must be a positive integer. The first few heptagonal numbers, for example, are: 1 is the first heptagonal number (corresponding to a heptagon with one dot). 7 is the second heptagonal number (corresponding to a heptagon with 7 dots). 18 is ... Read More

Cake Number

Simran Kumari
Updated on 23-Aug-2023 09:48:40

129 Views

What do you understand by the term `Cake Number`? Let's decode it in this article. The term "cake number" describes a concept of discrete geometry and combinatorics−related mathematical idea. It is built on the concept of the Lazy caterer's sequence. What is the Lazy Caterer's Sequence? The maximum number of pieces a disk (cake or pizza) can be sliced into using a specific number of straight slices is known as the Lazy caterer's sequence. Although it mentions a disk, we will consider a cake in our example. One straight cut can divide a cake into two pieces, two straight cuts ... Read More

Advantages and Disadvantages of Three-tier Architecture

Neetika Khandelwal
Updated on 22-Aug-2023 17:21:29

2K+ Views

A 3−tier application architecture is a modular client−server architecture that consists of a presentation tier, an application tier, and a data tier. The presentation tier is a graphical user interface (GUI) that interacts with the other two tiers; the data tier stores information; the application tier manages logic. A 3−tier architecture has pros in terms of better horizontal scalability, performance, and availability. When there are three layers, each component can be produced concurrently by a separate team of programmers using a different programming language than the developers of the other levels. The 3−tier paradigm makes it simpler for an organization ... Read More

Ways to choose three points with distance between the most distant points <= L

Rinish Patidar
Updated on 21-Aug-2023 20:58:49

121 Views

The problem states that we need to figure out the number of ways to choose three points with distance between the most distant points less than or equal to L, a positive integer that will be given as an input. In the problem we will be given an array of different points which lies on the x-axis and an integer L greater than 0. The task involves finding the number of sets of three points where the distance between the most distant points is less than or equal to that integer L. NOTE : The set of points ... Read More

Two Odd Occurring Elements in an Array where all Other Occur Even Times

Rinish Patidar
Updated on 21-Aug-2023 20:50:41

180 Views

The problem includes finding two odd occurring elements in an array where all other elements occur even times in C++. An array is a data structure in C++ which is used to store a list of elements in it of similar data types. We will be given an array of any size greater than or equal to 2 in input. The array will contain integers in it. Every integer in the array will occur even times except two integers which will be occurring odd times in the array. In this problem, we need to find out those two elements ... Read More

Sum of Product of r and rth Binomial Coefficient (r * nCr)

Rinish Patidar
Updated on 21-Aug-2023 20:45:57

137 Views

The problem states that we must determine the sum of the product of r and the rth binomial coefficient (r*nCr). Positive numbers that are coefficients in the binomial theorem are called binomial coefficients. Both Pascal's triangle and a straightforward formula can be used to determine the binomial coefficients. The formula for binomial coefficient is: $$\mathrm{n_{c_{r}}=\frac{n!}{(n-r)!r!}}$$ NOTE : The value of 0! is always equal to 1. In this equation n and r can be any non-negative integers and r should never be greater than n. The objective at hand in this problem entails computing the ... Read More

Subtract 1 Without Arithmetic Operators

Rinish Patidar
Updated on 21-Aug-2023 18:30:20

290 Views

This problem includes that we need to subtract 1 without using arithmetic operators. We will be given any integer N as input in the problem and we need to subtract 1 from the number or simply we need to print N-1. Our task is to perform the operation without using any arithmetic operators. The arithmetic operations involves variety of operations on numbers like addition(+), subtraction(-), multiplication(*), division(/), modulo(%), etc. These operations are supported by every programming language on numbers. Despite using this we need to subtract 1 from the number. For example, Input 7 Output 6 Explanation ... Read More

Sorting of Vector of Tuple in C++ (Ascending Order)

Rinish Patidar
Updated on 21-Aug-2023 18:12:03

1K+ Views

We will discuss sorting the vector of Tuple in C++ in ascending order in this article. A list of elements are stored in a C++ data structure known as a tuple. The same or different data types may be contained in it, and we may access them in the same sequence in which they were initialised as inputs. A tuple's data is organised so that we can retrieve it in the same order. Syntax tuple name In C++, this is how we can initialise a tuple. We may require few more tuple functions to sort the vector ... Read More

Set the Rightmost Unset Bit

Rinish Patidar
Updated on 21-Aug-2023 18:31:40

329 Views

The problem statement includes setting the rightmost unset bit of any positive integer N in C++. A bit is simply a binary digit of any number when represented in the form of a binary number. A binary number is the numerical representation of any data in the form of 0 and 1 where every bit(digit) of the number represents the power of 2 starting with 2^0 from the unit digit. Let's represent an integer 7 in the form of a binary number. The binary representation of 7 will be 111. These numbers can either be represented ... Read More

How to Turn on a Particular Bit in a Number?

Rinish Patidar
Updated on 21-Aug-2023 18:04:56

139 Views

The problem statement says that we need to turn on a particular bit in a number. To put it simply, all we have to do is swap out a certain bit in a number for 1. Provide the same outcome if it has already been 1. You can represent an integer using binary numbers, which come in the forms of 0 and 1 where every digit represents a power of 2. Let's represent 5 in the binary numbers. The binary form of 5 will be 101 i.e.$\mathrm{2^{2} + 2^{0}= 5.}$ In this problem, a number N will ... Read More

Advertisements