Found 7346 Articles for C++

Heptagonal number

Rinish Patidar
Updated on 16-Mar-2023 10:47:04

266 Views

A heptagonal number is a number which can be represented as a heptagon. A heptagon is a polygon with 7 sides. A heptagonal number can be represented as a combination of successive layers of heptagon( 7-sided polygon). Heptagonal number can be better explained with the below figures. The first heptagonal number is 1. Thus, it can be represented by a single dot. The second heptagonal number is 7 which can be represented by a heptagon. The third heptagonal number is 18 which can be represented as a heptagon and combined with a successive layer of heptagon. ... Read More

Find the GCD that lies in given range

Rinish Patidar
Updated on 16-Mar-2023 10:25:14

418 Views

The problem states that we need to find the GCD that lies in the given range. We will be given two positive integers, x and y and two integers p and q which will be the range as [p, q]. We need to find out the GCD (greatest common divisor) of the numbers x and y falling under the range [p, q]. GCD, known as greatest common divisor in mathematics, is the greatest positive integer dividing each of two given positive integers. The given integers must not be zero. It is represented as gcd(x, y) for any two positive integers ... Read More

Check whether a given number is Polydivisible or Not

Rinish Patidar
Updated on 16-Mar-2023 10:22:33

261 Views

The problem statement includes checking whether a given number is Polydivisible or not for any given integer N. A polydivisible number, also known as magic number, is a number following a unique pattern. The number created by first p digits of the given number should always be divisible by p and there should not be any leading zeros in the given number. If a number satisfies these properties, it is a Polydivisible number, else it is not. Here, p should be in range (1, total digits in the given number). Let’s understand the concept of polydivisible number with an example: ... Read More

Check if the n-th term is odd or even in a Fibonacci like sequence

Rinish Patidar
Updated on 16-Mar-2023 10:18:26

253 Views

Our task in this problem is to check if the n-th term of a fibonacci like sequence is odd or even. A fibonacci sequence is a type of sequence in mathematics where each number in the sequence is the sum of the preceding two numbers. A nth term of the fibonacci sequence can be represented as − $$\mathrm{Fn\:=\:F_{n-1}\:+\:F_{n-2}}$$ The first few numbers of the fibonacci sequence are 0, 1, 1, 2, 3, 5, 8, 13, 21, 34….. The first two numbers of the sequence are 0 and 1. The next numbers are the sum of the preceding two ... Read More

Centered Tridecagonal Number

Rinish Patidar
Updated on 16-Mar-2023 10:14:12

117 Views

The problem statement states that we need to print the N-th centred Hexadecagon numbers for any positive number N. Tridecagonal numbers are the numbers that represent a tridecagon in itself. A tridecagon in mathematics is a polygon which has 13 sides. A centred tridecagonal numbers are the numbers that can be represented in the form of a dot in the centre followed by other dots surrounding it in successive layers of tridecagon which is nothing but a 13-sided polygon. Let’s understand the concept of centred tridecagonal numbers better with the figures. The first centred tridecagonal number can just ... Read More

Centered Hexadecagonal Number

Rinish Patidar
Updated on 16-Mar-2023 10:01:42

117 Views

Hexadecagonal numbers are the numbers that represent a hexadecagon. Hexadecagon is a polygon which consists of 16 sides. A Centred Hexadecagonal number is the number represented by a dot in the centre and other dots surrounding it in the successive hexadecagonal layers i.e. 16 sided polygon. We can understand the centred hexadecagonal number better with the below figures. There is a single dot in the centre for the first centred hexadecagon number. So the first centred hexadecagonal number will be 1. There is a single dot followed by a hexadecagon surrounding it in the next centred hexadecagon number. ... Read More

Sentence Case of a given Camel cased String

Mallika Gupta
Updated on 15-Mar-2023 11:35:16

530 Views

A C++ string is a collection of characters forming words. It may contains letters, numbers and even special characters. The sentences of a string can be clubbed together in different ways to form different types of representations. The camel case of a string denotes the string in such a way that the following two properties are maintained − The words are joined together, there is no space character. Every word has the first letter stored in upper case. Thereby, the upper case letters in this form of representation can be used to segregate the different words. This type ... Read More

Reverse Individual Words With O(1) Extra Space

Mallika Gupta
Updated on 15-Mar-2023 11:32:48

491 Views

A string may be composed of several words. Every word in a C++ string may contain letters, numbers or special symbols. Strings are considered to be storage elements for these kind of characters. Each word is separated by a space character. Each word also forms a string of characters. Reverse of any string in C++ is the string follows the following points − It is formed by taking characters from the end towards the beginning. The length of the original string remains unchanged. The order of occurrence of characters in a string can be reversed easily by swapping ... Read More

Rearrange the given string such that all Prime Multiple indexes have Same Character

Mallika Gupta
Updated on 15-Mar-2023 11:21:57

99 Views

A string is a sequence of characters, numbers, Alphanumeric characters and special characters. The length of a string is the number of characters that are present in it. A prime number is the number which is divisible by 1 and the number itself. In this artice, we are given a sample input string of length n. We are going to develop a code where the idea is to substitute the same character at any position p, such that the the characters at positions ranging from 1 to n/p should coincide. Some of the examples illustrating the problem statement ... Read More

Minimum Number of Adjacent Awaps to Convert a String into its given Anagram

Mallika Gupta
Updated on 15-Mar-2023 11:15:35

502 Views

Every string is formed by a sequence of characters arranged in an order. The string may be composed of letters, number or even special characters. An anagram of any input string, is the string with a random permutation of characters. This implies, that when the order of the characters is rearranged, an anagram of the string is obtained. The respective counts of the characters should also remain the same in anagrams. Two anagram strings have the following implications − Both of them contains the same set of characters. Both of them may have a different permutation of characters ... Read More

Advertisements