Add Elements to Array Until Each Element is Greater Than or Equal to K

sudhir sharma
Updated on 07-Oct-2019 07:36:17

198 Views

We have array of unsorted element i.e. arr[] and have an integer K, and we have to find the minimum number of steps needed in which the elements of the array will be added to make all the elements greater than or equal to K. We can add two elements of array and make them one.Example, Input: arr[] = {1 10 12 9 2 3}, K = 6 Output: 2ExplanationFirst we can add (1 + 2), so the new array is 3 10 12 9 3, we can add (3 + 3), So the new array is 6 10 12 ... Read More

Check If a Given String is a Keyword in C

sudhir sharma
Updated on 07-Oct-2019 07:28:38

13K+ Views

Keyword is a predefined or reserved word which is available in C++ library with a fixed meaning and used to perform an internal operation. C++ Language supports more than 64 keywords.Every Keyword exists in lower case letters like auto, break, case, const, continue, int etc.32 Keywords in C++ Language which is also available in the C language.autodoubleintstructbreakelselongswitchcaseenumregistertypedefcharexternreturnunionconstfloatshortunsignedcontinueforsignedvoiddefaultgotosizeofvolatiledoifstaticwhileThese are 30 reserved words that were not in C, but added to C++asmdynamic_castnamespacereinterpret_castboolexplicitnewstatic_castcatchfalseoperatortemplateclassfriendprivatethisconst_castinlinepublicthrowdeletemutableprotectedtruetrytypeidtypenameusingusingusingwchar_tInput: str=”for” Output: for is a keywordExplanationKeywords are reserved words which cannot be used as variable names in program.There are 32 keywords in the C programming language.Compare the string with each ... Read More

Sum of the Series 1 + 2 + 3 + ... + n + (n+1) + (n+2) in C

sudhir sharma
Updated on 07-Oct-2019 07:23:56

695 Views

Find the sum up to n terms of the series: 1.2.3 + 2.3.4 + … + n(n+1)(n+2). In this 1.2.3 represent the first term and 2.3.4 represent the second term.Let’s see an example to understand the concept better, Input: n = 5 Output: 420Explanation1.2.3 + 2.3.4 + 3.4.5 + 4.5.6 + 5.6.7 = 6 + 24 + 60 + 120 + 210 = 420nth term = n(n+1)(n+2); where n = 1, 2, 3, …= n(n^2+3n+2)=n^3 +3n^2 +2nNow, noteSum =n(n+1)/2 ; if nth term =n=n(n+1)(2n+1)/6 ; if nth term =n^2=n^2(n+1)^2/4 ; if nth term =n^3Hence the required sum =n^2(n+1)^2 /4 + ... Read More

Biggest Square Inscribed in Equilateral Triangle in C

sudhir sharma
Updated on 07-Oct-2019 07:19:35

149 Views

An inscribed planar shape or solid is one that is enclosed by and "fits snugly" inside another geometric shape or solid. To say that "square is inscribed in triangle" means precisely the same thing as "triangle is circumscribed about square".Biggest Square that can be inscribed within an Equilateral triangle −Biggest Square that can be inscribed within an Equilateral triangle −Let’s take an example, Input: 5 Output: 2.32ExplanationThe side of the square be x.Now, AH is perpendicular to DE.DE is parallel to BC, angle AED = angle ACB = 60In triangle EFC,    ⇒ Sin60 = x/ EC   ⇒ √3 / ... Read More

Biggest Reuleaux Triangle Within a Square in C

sudhir sharma
Updated on 07-Oct-2019 07:14:34

129 Views

A Reuleaux triangle is a shape formed from the intersection of three circular disks, each having its center on the boundary of the other two. Its boundary is a curve of constant width, the simplest and best known such curve other than the circle itself. Constant width means that the separation of every two parallel supporting lines is the same, independent of their orientation. Because all its diameters are the same.The boundary of a Reuleaux triangle is a constant width curve based on an equilateral triangle. All points on a side are equidistant from the opposite vertex.To construct a Reuleaux ... Read More

Biggest Reuleaux Triangle Within a Square Inscribed in a Circle in C

sudhir sharma
Updated on 07-Oct-2019 07:12:03

167 Views

A Reuleaux triangle is a shape formed from the intersection of three circular disks, each having its center on the boundary of the other two. Its boundary is a curve of constant width, the simplest and best known such curve other than the circle itself. Constant width means that the separation of every two parallel supporting lines is the same, independent of their orientation. Because all its diameters are the same.The boundary of a Reuleaux triangle is a constant width curve based on an equilateral triangle. All points on a side are equidistant from the opposite vertex.To construct a Reuleaux triangleFormula for Reuleaux triangleArea of the Reuleaux ... Read More

Biggest Reuleaux Triangle Within a Square Inscribed in Right Angle Triangle in C

sudhir sharma
Updated on 07-Oct-2019 07:09:13

113 Views

A Reuleaux triangle is a shape formed from the intersection of three circular disks, each having its center on the boundary of the other two. Its boundary is a curve of constant width, the simplest and best known such curve other than the circle itself. Constant width means that the separation of every two parallel supporting lines is the same, independent of their orientation. Because all its diameters are the same.The boundary of a Reuleaux triangle is a constant width curve based on an equilateral triangle. All points on a side are equidistant from the opposite vertex.To construct a Reuleaux ... Read More

Biggest Reuleaux Triangle Inscribed Within a Square in C

sudhir sharma
Updated on 07-Oct-2019 07:06:14

143 Views

A Reuleaux triangle is a shape formed from the intersection of three circular disks, each having its center on the boundary of the other two. Its boundary is a curve of constant width, the simplest and best known such curve other than the circle itself. Constant width means that the separation of every two parallel supporting lines is the same, independent of their orientation. Because all its diameters are the same.The boundary of a Reuleaux triangle is a constant width curve based on an equilateral triangle. All points on a side are equidistant from the opposite vertex.To construct a Reuleaux ... Read More

Biggest Reuleaux Triangle Inscribed Within a Square in C

sudhir sharma
Updated on 07-Oct-2019 07:03:02

134 Views

A Reuleaux triangle is a shape formed from the intersection of three circular disks, each having its center on the boundary of the other two. Its boundary is a curve of constant width, the simplest and best known such curve other than the circle itself. Constant width means that the separation of every two parallel supporting lines is the same, independent of their orientation. Because all its diameters are the same.The boundary of a Reuleaux triangle is a constant width curve based on an equilateral triangle. All points on a side are equidistant from the opposite vertex.To construct a Reuleaux ... Read More

Sorting Using Selection Sort in 8085 Microprocessor

Arnab Chakraborty
Updated on 05-Oct-2019 11:39:08

431 Views

Here we will see one microprocessor program using 8085. In this program we will see how to sort a sequence of numbers using selection sort.Problem Statement −Write an 8085 Assembly language program to sort a given sequence using selection sort in ascending order. The numbers are stored at 8001H onwards. 8000H is holding the block size.Discussion −In the selection sorting technique, we will choose the minimum or the maximum term from a set of numbers. In this case we are considering the sorting in ascending order, so we are choosing the minimum number. By taking the minimum number, we are swapping it ... Read More

Advertisements