C++ Program for Area Of Square after N-th fold

Sunidhi Bansal
Updated on 23-Sep-2019 11:50:02

85 Views

Given a side of a square and the number of fold, we have to find the Area of square after number of folds.A square is a 2-D shape like rectangle where all the sides are equal. And it’s all angles are equal to 90 degrees.While folding a square we −Fold the square from top left side of the triangle to the bottom of the right side forming a triangle.The second fold will be folding from up to downside.The third fold is folding again from left to right.And likewise we follow the above steps.ExamplesInput: side = 23, fold = 4 Output: ... Read More

C Program for Area And Perimeter Of Rectangle

Sunidhi Bansal
Updated on 23-Sep-2019 11:47:18

3K+ Views

Given a length and breadth of a rectangle we have to find its area and Perimeter.Rectangle is 2-D figure containing four sides and four angles of 90 degree each. All the sides of rectangle are not equal only the opposite sides of a rectangle are equal. The diagonals in a rectangle also are of the same length.Below is a diagrammatic representation of rectangle.Here A represents the breadth and B represents length of the rectangle.To find the Area of a rectangle the formula is: Length x BreadthAnd Perimeter of a rectangle is − 2 x (Length+Breadth).ExamplesInput: 20 30 Output: area of rectangle ... Read More

C Program for n-th odd number

Sunidhi Bansal
Updated on 23-Sep-2019 11:46:16

777 Views

Given a number N we have to find the N-th odd number.Odd numbers are the numbers which are not completely divided by 2 and their remainder is not zero. Like 1, 3, 5, 7, 9, ….If we closely observe the list of even numbers we can also represent them as(2*1)-1=1, (2*2)-1=3, ( 2*3)-1=5, (2*4)-1=7, ….(2*N)-1.So, to solve the problem we can simply multiply the number N with 2 and subtract 1 from the result, that makes up an odd number.ExamplesInput: 4 Output: 7 The 4th odd number is 1, 3, 5, 7.. Input: 10 Output: 19AlgorithmSTART    STEP 1 -> ... Read More

C Program for n-th even number

Sunidhi Bansal
Updated on 23-Sep-2019 11:39:33

441 Views

Given a number N we have to find the N-th even number.Even numbers are the numbers which are completely divided by 2 and their remainder is zero. Like 2, 4, 6, 8, 10, ….If we closely observe the list of even numbers we can also represent them as2*1=2, 2*2=4, 2*3=6, 2*4=8, ….2*N.So, to solve the problem we can simply multiply the number N with 2, so the result will be the number which is divisible by 2, i.e. the even number.ExampleInput: n = 4 Output: 8 The first 4 even numbers will be 2, 4, 6, 8, .. Input: ... Read More

HTML DOM Style tabSize Property

AmitDiwan
Updated on 23-Sep-2019 11:38:40

37 Views

The HTML DOM Style tabSize property returns and modify the length of the space used for the tab character in an HTML document.SyntaxFollowing is the syntax −1. Returning tabSizeobject.tabSize2. Modifying tabSizeobject.tabSize = “value”Here value can be −ValueExplanationinitialIt set this property value to its default value.inheritIt inherits this property value from its parent element.lengthIt specifies the length of a tab character.numberIt specifies the number of space-characters that should be displayed for each tab-character in an HTML document.Let us see an example of HTML DOM Style tabSize Property −Example    body {       color: #000;       ... Read More

Program to check if N is a Pentagonal Number in C++

Sunidhi Bansal
Updated on 23-Sep-2019 11:37:11

411 Views

Given with a number N the task is to check whether the number is a pentagonal number or not. Numbers that can be arranged to form a pentagon is a pentagonal number as these numbers can be used as points to form a pentagon. For example, some of pentagonal numbers are 1, 5, 12, 22, 35, 51....We can use formula to check whether the number is a pentagonal number or not$$p(n)=\frac{\text{3}*n^2-n}{\text{2}}$$Where, n is the number of points pentagonal will haveExampleInput-: n=22 Output-: 22 is pentagonal number Input-: n=23 Output-: 23 is not a pentagonal numberAlgorithmStart Step 1 -> declare function ... Read More

C++ Program to Convert Km/hr to miles/hr and vice versa

Sunidhi Bansal
Updated on 23-Sep-2019 11:12:51

406 Views

If input is in km/hr convert it to miles/hr else input will be in miles/hr convert it to km/hr. There are formulas that can be used for this conversion.Conversion Formulas −1 kilo-metre = 0.621371 miles 1 miles = 1.60934 Kilo-meterExampleInput-: kmph= 50.00    Mph = 10.00 Output-: speed in m/ph is 31.07    speed in km/ph is 16.0934AlgorithmStart Step 1 -> Declare function to convert km/ph to m/ph    double km_mph(double km)       return 0.6214 * km step 2 -> Declare function to convert m/ph to km/ph    double m_km(double m_ph)       return m_ph * 1.60934 ... Read More

C++ Program to Convert Hexadecimal Number to Binary

Sunidhi Bansal
Updated on 23-Sep-2019 11:10:09

988 Views

Given with hexadecimal number as an input, the task is to convert that hexadecimal number into a binary number.Hexadecimal number in computers is represented with base 16 and binary number is represented with base 2 as it has only two binary digits 0 and 1 whereas hexadecimal number have digits starting from 0 – 15 in which 10 is represented as A, 11 as B, 12 as C, 13 as D, 14 as E and 15 as F.To convert hexadecimal number into binary number every number is converted into its binary equivalent of 4 bits and after that these numbers ... Read More

Program to convert speed in km/hr to m/sec and vice versa in C++

Sunidhi Bansal
Updated on 23-Sep-2019 11:00:19

527 Views

Conversion Formulas −1 km/hr = 5/18 m/sec or 0.277778 m/sec 1 m/sec = 18/5 km/hr or 3.6 km/hrExampleInput-: km = 60.00    mk = 70.00 Output-: speed in meter per second = 16.6667    speed in km per hour = 252AlgorithmStart Step 1 -> Declare function to convert km/hr into m/sec    float km_m(float km)       return (0.277778 * km) Step 2 -> Declare function to convert m/sec into km/hr    float m_km(float mk)       return (3.6 * mk) step 3 -> In main()    declare variable as float km = 60.0 and float mk = ... Read More

Program to Convert Radian to Degree in C

Sunidhi Bansal
Updated on 23-Sep-2019 10:58:09

1K+ Views

If input is in radian convert it to degree else input will be in radian convert it to degree. There are formulas that can be used for this conversion.Radian is the standard unit for measuring angles whereas the complete angle of circle is divided into 360 degree. Also, radian is the smaller value as 1 degree = 180 radians.Conversion Formulas −degree = radian * (180/pi) where, pi=3.14 or 22/7ExampleInput-: radian = 9.0 Output-: degree is : 515.92357AlgorithmStart Step 1 -> define macro as #define pi 3.14 Step 2 -> declare function for converting radian to degree    double convert(double radian) ... Read More

Advertisements