codeparrot/xlcost-text-to-code huggingface dataset:
Length of remaining two sides of a Triangle from a given side and its adjacent angles | Function for computing other 2 side of the trianlgle ; Computing angle C ; Converting A in to radian ; Converting B in to radian ; Converting C in to radian ; Computing length of side b ; Computing length of side c ; Driver code ; Calling function
function findSide ( a , B , C ) { var A = 180 - C - B ; var radA = Math . PI * ( A / 180 ) ; var radB = Math . PI * ( B / 180 ) ; var radC = Math . PI * ( C / 180 ) ; var b = a / Math . sin ( radA ) * Math . sin ( radB ) ; var c = a / Math . sin ( radA ) * Math . sin ( radC ) ; document . write ( b + " " ) ; document . write ( c ) ; } var a = 12 , B = 60 , C = 30 ; findSide ( a , B , C ) ;
Minimum area of square holding two identical rectangles | Function to find the area of the square ; Larger side of rectangle ; Smaller side of the rectangle ; Driver Code
function areaSquare ( L , B ) { let large = Math . max ( L , B ) ; let small = Math . min ( L , B ) ; if ( large >= 2 * small ) { return large * large ; } else { return ( 2 * small ) * ( 2 * small ) ; } } let L = 7 ; let B = 4 ; document . write ( areaSquare ( L , B ) ) ;
Minimum side of square embedded in Regular polygon with N sides | PI value in Java using acos function ; Function to find the minimum side of the square in which a regular polygon with even sides can completely embed ; Projection angle variation from axes ; Projection angle variation when the number of sides are in multiple of 4 ; Distance between the end polets ; Projection from all N polets on X - axis ; Projection from all N polets on Y - axis ; Maximum side ; Return the portion of side forming the square ; Driver code
let pi = Math . acos ( - 1.0 ) ; function nGon ( N ) { let proAngleVar ; if ( N % 4 == 0 ) { proAngleVar = pi * ( 180.0 / N ) / 180 ; } else { proAngleVar = pi * ( 180.0 / ( 2 * N ) ) / 180 ; } let negX = 1.0e+99 , posX = - 1.0e+99 , negY = 1.0e+99 , posY = - 1.0e+99 ; for ( let j = 0 ; j < N ; ++ j ) { let px = Math . cos ( 2 * pi * j / N + proAngleVar ) ; let py = Math . sin ( 2 * pi * j / N + proAngleVar ) ; negX = Math . min ( negX , px ) ; posX = Math . max ( posX , px ) ; negY = Math . min ( negY , py ) ; posY = Math . max ( posY , py ) ; } let opt2 = Math . max ( posX - negX , posY - negY ) ; return opt2 / Math . sin ( pi / N ) / 2 ; } let N = 10 ; document . write ( nGon ( N ) . toFixed ( 5 ) ) ;
Heptacontagon Number | Finding the nth heptacontagon number ; Driver code
function heptacontagonNum ( n ) { return ( 68 * n * n - 66 * n ) / 2 ; } var N = 3 ; document . write ( " " + heptacontagonNum ( N ) ) ;
Program to check if N is a Icositetragonal number | Function to check that the number is a icositetragonal number ; Condition to check if the number is a icositetragonal number ; Driver Code ; Function call
function isicositetragonal ( N ) { var n = ( 10 + Math . sqrt ( 44 * N + 100 ) ) / 22 ; return ( n - parseInt ( n ) ) == 0 ; } var i = 24 ; if ( isicositetragonal ( i ) ) { document . write ( " " ) ; } else { document . write ( " " ) ; }
Program to check if N is a Tridecagonal Number or not | Function to check that the number is a Tridecagon number ; Condition to check if the number is a Tridecagon number ; Driver Code ; Function call
function isTridecagon ( N ) { var n = ( 9 + Math . sqrt ( 88 * N + 81 ) ) / 22 ; return ( n - parseInt ( n ) ) == 0 ; } var i = 13 ; if ( isTridecagon ( i ) ) { document . write ( " " ) ; } else { document . write ( " " ) ; }
Program to check if N is a Icosihenagonal number | Function to check that the number is a icosihenagonal number ; Condition to check if the number is a icosihenagonal number ; Driver Code ; Function call
function isicosihenagonal ( N ) { var n = ( 17 + Math . sqrt ( 152 * N + 289 ) ) / 38 ; return ( n - parseInt ( n ) ) == 0 ; } var i = 21 ; if ( isicosihenagonal ( i ) ) { document . write ( " " ) ; } else { document . write ( " " ) ; }
Program to check if N is a Icositrigonal number | Function to check that the number is a icositrigonal number ; Condition to check if the number is a icositrigonal number ; Driver Code ; Function call
function isicositrigonal ( N ) { var n = ( 19 + Math . sqrt ( 168 * N + 361 ) ) / 42 ; return ( n - parseInt ( n ) ) == 0 ; } var i = 23 ; if ( isicositrigonal ( i ) ) { document . write ( " " ) ; } else { document . write ( " " ) ; }
Check whether triangle is valid or not if three points are given | Function to check if three points make a triangle ; Calculation the area of triangle . We have skipped multiplication with 0.5 to avoid floating point computations ; Condition to check if area is not equal to 0 ; Driver Code
function checkTriangle ( x1 , y1 , x2 , y2 , x3 , y3 ) { let a = x1 * ( y2 - y3 ) + x2 * ( y3 - y1 ) + x3 * ( y1 - y2 ) ; if ( a == 0 ) document . write ( " " ) ; else document . write ( " " ) ; } let x1 = 1 , x2 = 2 , x3 = 3 , y1 = 1 , y2 = 2 , y3 = 3 ; checkTriangle ( x1 , y1 , x2 , y2 , x3 , y3 ) ;
Total number of triplets ( A , B , C ) in which the points B and C are Equidistant to A | Function to size ( ) such triplets ; Iterate over all the points ; Iterate over all points other than the current point ; Compute squared euclidean distance for the current point ; Compute nP2 that is n * ( n - 1 ) ; Return the final result ; Driver code
function numTrip ( points ) { let res = 0 ; for ( let i = 0 ; i < points . length ; ++ i ) { let map = new Map ( ) ; for ( let j = 0 ; j < points . length ; ++ j ) { if ( j == i ) continue ; let dy = points [ i ] [ 1 ] - points [ j ] [ 1 ] ; let dx = points [ i ] [ 0 ] - points [ j ] [ 0 ] ; let key = dy * dy ; key += dx * dx ; if ( map . has ( key ) ) { map . set ( key , map . get ( key ) + 1 ) ; } else { map . set ( key , 1 ) ; } } for ( let [ key , value ] of map . entries ( ) ) res += value * ( value - 1 ) ; } return res ; } let mat = [ ] ; mat . push ( [ 0 , 0 ] ) ; mat . push ( [ 1 , 0 ] ) ; mat . push ( [ 2 , 0 ] ) ; document . write ( numTrip ( mat ) ) ;
Check if any point overlaps the given Circle and Rectangle | Function to check if any point overlaps the given circle and rectangle ; Find the nearest point on the rectangle to the center of the circle ; Find the distance between the nearest point and the center of the circle Distance between 2 points , ( x1 , y1 ) & ( x2 , y2 ) in 2D Euclidean space is ( ( x1 - x2 ) * * 2 + ( y1 - y2 ) * * 2 ) * * 0.5 ; Driver Code
function checkOverlap ( R , Xc , Yc , X1 , Y1 , X2 , Y2 ) { let Xn = Math . max ( X1 , Math . min ( Xc , X2 ) ) ; let Yn = Math . max ( Y1 , Math . min ( Yc , Y2 ) ) ; let Dx = Xn - Xc ; let Dy = Yn - Yc ; return ( Dx * Dx + Dy * Dy ) <= R * R ; } let R = 1 ; let Xc = 0 , Yc = 0 ; let X1 = 1 , Y1 = - 1 ; let X2 = 3 , Y2 = 1 ; if ( checkOverlap ( R , Xc , Yc , X1 , Y1 , X2 , Y2 ) ) { document . write ( " " + " " ) ; } else { document . write ( " " ) ; }
Check if the tower of sight issue occurs or not | Function to check if point p lies in between the line joining p1 and p2 ; If parallel to X - axis ; Point p lies between p1 and p2 ; If parallel to Y - axis ; Point p lies between p1 and p2 ; If point p satisfies the equation of line joining p1 and p2 ; Function to check if tower of sight issue occurred ; B lies between AC ; D lies between AC ; A lies between BD ; C lies between BD ; Point A ; Point B ; Point C ; Point D
function checkIntersection ( p1 , p2 , p ) { let val ; if ( p1 [ 1 ] == p2 [ 1 ] && p1 [ 1 ] == p [ 1 ] ) { if ( p [ 0 ] <= Math . max ( p1 [ 0 ] , p2 [ 0 ] ) && ( p [ 0 ] >= Math . min ( p1 [ 0 ] , p2 [ 0 ] ) ) ) return 1 ; } if ( p1 [ 0 ] == p2 [ 0 ] && p1 [ 0 ] == p [ 0 ] ) { if ( p [ 1 ] <= Math . max ( p1 [ 1 ] , p2 [ 1 ] ) && ( p [ 1 ] >= Math . min ( p1 [ 1 ] , p2 [ 1 ] ) ) ) return 1 ; } else { val = ( p [ 1 ] - p1 [ 1 ] ) * ( p2 [ 0 ] - p1 [ 0 ] ) - ( p [ 0 ] - p1 [ 0 ] ) * ( p2 [ 1 ] - p1 [ 1 ] ) ; if ( val == 0 ) if ( ( p [ 0 ] <= Math . max ( p1 [ 0 ] , p2 [ 0 ] ) && ( p [ 0 ] >= Math . min ( p1 [ 0 ] , p2 [ 0 ] ) ) ) && ( p [ 1 ] <= Math . max ( p1 [ 1 ] , p2 [ 1 ] ) && ( p [ 1 ] >= Math . min ( p1 [ 1 ] , p2 [ 1 ] ) ) ) ) return 1 ; } return 0 ; } function towerOfSight ( a , b , c , d ) { let flag = 0 ; if ( checkIntersection ( a , c , b ) == 1 ) flag = 1 ; else if ( checkIntersection ( a , c , d ) == 1 ) flag = 1 ; else if ( checkIntersection ( b , d , a ) == 1 ) flag = 1 ; else if ( checkIntersection ( b , d , c ) == 1 ) flag = 1 ; document . write ( flag == 1 ? " " : " " ) ; } let a = [ 0 , 0 ] ; let b = [ 0 , - 2 ] ; let c = [ 2 , 0 ] ; let d = [ 0 , 2 ] ; towerOfSight ( a , b , c , d ) ;
Number of lines from given N points not parallel to X or Y axis | Function to find the number of lines which are formed from given N points and not parallel to X or Y axis ; This will store the number of points has same x or y coordinates using the map as the value of coordinate can be very large ; Counting frequency of each x and y coordinates ; Total number of pairs can be formed ; We can not choose pairs from these as they have same x coordinatethus they will result line segment parallel to y axis ; we can not choose pairs from these as they have same y coordinate thus they will result line segment parallel to x - axis ; Return the required answer ; Driver Code ; Function call
function NotParallel ( p , n ) { var x_axis = new Map ( ) , y_axis = new Map ( ) ; for ( var i = 0 ; i < n ; i ++ ) { if ( x_axis . has ( p [ i ] [ 0 ] ) ) x_axis . set ( p [ i ] [ 0 ] , x_axis . get ( p [ i ] [ 0 ] ) + 1 ) else x_axis . set ( p [ i ] [ 0 ] , 1 ) if ( y_axis . has ( p [ i ] [ 1 ] ) ) y_axis . set ( p [ i ] [ 1 ] , y_axis . get ( p [ i ] [ 1 ] ) + 1 ) else y_axis . set ( p [ i ] [ 1 ] , 1 ) } var total = ( n * ( n - 1 ) ) / 2 ; x_axis . forEach ( ( value , key ) => { var c = value ; total -= ( c * ( c - 1 ) ) / 2 ; } ) ; y_axis . forEach ( ( value , key ) => { var c = value ; total -= ( c * ( c - 1 ) ) / 2 ; } ) ; return total ; } var p = [ [ 1 , 2 ] , [ 1 , 5 ] , [ 1 , 15 ] , [ 2 , 10 ] ] ; var n = p . length ; document . write ( NotParallel ( p , n ) ) ;
Check whether two convex regular polygon have same center or not | Function to check whether two convex polygons have the same center or not ; Driver code
function check ( n , m ) { if ( m % n == 0 ) { document . write ( " " ) ; } else { document . write ( " " ) ; } return 0 ; } var n = 5 ; var m = 10 ; check ( n , m ) ;
Minimum number of blocks required to form Hollow Rectangular Prism | Function to display output ; Function to return minimum no of layers required to form the hollow prism ; Function to calculate no of blocks required for each layer ; No of blocks required for each row ; Check for no of layers is minimum ; Length , width , height of each block ; Side of one wall ; height of each wall
function disp ( row_no , block ) { document . write ( row_no * block ) ; } function row ( ht , h ) { return ht / h ; } function calculate ( l , w , h , a , ht ) { let no_block = ( 4 * a ) / l ; let row_no ; if ( h < w ) row_no = row ( ht , w ) ; else row_no = row ( ht , h ) ; disp ( row_no , no_block ) ; } let l = 50 , w = 20 , h = 35 ; let a = 700 ; let ht = 140 ; calculate ( l , w , h , a , ht ) ;
Maximum area of rectangle inscribed in an equilateral triangle | Function to find the maximum area of the rectangle inscribed in an equilateral triangle of side S ; Maximum area of the rectangle inscribed in an equilateral triangle of side S ; Driver Code
function solve ( s ) { let area = ( 1.732 * Math . pow ( s , 2 ) ) / 8 ; return area ; } let n = 14 ; document . write ( solve ( n ) ) ;
Area of largest semicircle that can be drawn inside a square | Function to find area of semicircle ; side of a square ; Call Function to find the area of semicircle
function find_Area ( a ) { var R = a * ( 2.0 - Math . sqrt ( 2 ) ) ; var area = 3.14 * R * R / 2.0 ; return area ; } var a = 4 ; document . write ( " " + find_Area ( a ) ) ;
Count the number of times graph crosses X | Function to to count the number of times the graph crosses the x - axis . ; Iterate over the steps array ; Update the previous level and current level by value given in the steps array ; Condition to check that the graph crosses the origin . ; Driver Code
function times ( steps , n ) { let current_level = 0 ; let previous_level = 0 ; let count = 0 ; for ( let i = 0 ; i < n ; i ++ ) { previous_level = current_level ; current_level = current_level + steps [ i ] ; if ( ( previous_level < 0 && current_level >= 0 ) || ( previous_level > 0 && current_level <= 0 ) ) { count ++ ; } } return count ; } let steps = [ 1 , - 1 , 0 , 0 , 1 , 1 , - 3 , 2 ] ; let n = steps . length ; document . write ( times ( steps , n ) ) ;
Program to find X , Y and Z intercepts of a plane | Javascript program to find the X , Y and Z intercepts of a plane ; For finding the x - intercept put y = 0 and z = 0 ; For finding the y - intercept put x = 0 and z = 0 ; For finding the z - intercept put x = 0 and y = 0 ; For Finding value of A , B , C , D ; Calling the first created function ; Driver Code
function XandYandZintercept ( A , B , C , D ) { let rslt = new Array ( 3 ) ; let x = - D / A ; let y = - D / B ; let z = - D / C ; rslt [ 0 ] = x ; rslt [ 1 ] = y ; rslt [ 2 ] = z ; return rslt ; } function equation_plane ( p , q , r ) { let x1 = p [ 0 ] ; let y1 = p [ 1 ] ; let z1 = p [ 2 ] ; let x2 = q [ 0 ] ; let y2 = q [ 1 ] ; let z2 = q [ 2 ] ; let x3 = r [ 0 ] ; let y3 = r [ 1 ] ; let z3 = r [ 2 ] ; let a1 = x2 - x1 ; let b1 = y2 - y1 ; let c1 = z2 - z1 ; let a2 = x3 - x1 ; let b2 = y3 - y1 ; let c2 = z3 - z1 ; let A = b1 * c2 - b2 * c1 ; let B = a2 * c1 - a1 * c2 ; let C = a1 * b2 - b1 * a2 ; let D = ( - A * x1 - B * y1 - C * z1 ) ; let rslt = XandYandZintercept ( A , B , C , D ) ; for ( let i = 0 ; i < 3 ; i ++ ) { document . write ( rslt [ i ] + " " ) ; } } let x1 = - 1 ; let y1 = 2 ; let z1 = 1 ; let x2 = 0 ; let y2 = - 3 ; let z2 = 2 ; let x3 = 1 ; let y3 = 1 ; let z3 = - 4 ; let p = [ x1 , y1 , z1 ] ; let q = [ x2 , y2 , z2 ] ; let r = [ x3 , y3 , z3 ] ; equation_plane ( p , q , r ) ;
Percentage change in Hemisphere volume if radius is changed | Function to find the change in hemispheric volume ; Get the change in radius ; Calculate the change in hemispheric volume
function new_vol ( x ) { if ( x > 0 ) { document . write ( " " + " " + ( Math . pow ( x , 3 ) / 10000 + 3 * x + ( 3 * Math . pow ( x , 2 ) ) / 100 ) + " " + " " ) ; } else if ( x < 0 ) { document . write ( " " + " " + ( Math . pow ( x , 3 ) / 10000 + 3 * x + ( 3 * Math . pow ( x , 2 ) ) / 100 ) + " " ) ; } else { document . write ( " " ) ; } } var x = - 10.0 ; new_vol ( x ) ;
Find the integer points ( x , y ) with Manhattan distance atleast N | C ++ function to find all possible point ; Find all 4 corners of the square whose side length is n ; If n is even then the middle point of the square will be an integer , so we will take that point ; Driver Code ; Printing all possible points
function FindPoints ( n ) { var v = [ ] ; v . push ( [ 0 , 0 ] ) ; v . push ( [ 0 , n ] ) ; v . push ( [ n , 0 ] ) ; v . push ( [ n , n ] ) ; if ( n % 2 == 0 ) v . push ( [ n / 2 , n / 2 ] ) ; return v ; } var N = 8 ; var v = FindPoints ( N ) ; v . forEach ( i => { document . write ( " " + i [ 0 ] + " " + i [ 1 ] + " " ) ; } ) ;
Find if the glass will be empty or not when the rate of drinking is given | JavaScript implementation of the approach ; Function to return the time when the glass will be empty ; Check the condition when the glass will never be empty ; Find the time ; Driver code
const pie = 3.1415926535897 ; function findsolution ( d , h , m , n ) { var k = ( 4 * m ) / ( pie * d * d ) ; if ( n > k ) return - 1 ; var ans = ( h / ( k - n ) ) ; return ans ; } var d = 1 , h = 1 , m = 1 , n = 1 ; document . write ( findsolution ( d , h , m , n ) . toFixed ( 5 ) ) ;
Sum of internal angles of a Polygon | Function to return the sum of internal angles of an n - sided polygon ; Driver code
function sumOfInternalAngles ( n ) { if ( n < 3 ) return 0 ; return ( n - 2 ) * 180 ; } let n = 5 ; document . write ( sumOfInternalAngles ( n ) ) ;
Number of ways N can be divided into four parts to construct a rectangle | Function to return the required number of ways ; Driver code
function cntWays ( n ) { if ( n % 2 == 1 ) { return 0 ; } else { return ( n - 2 ) / 4 ; } } var n = 18 ; document . write ( cntWays ( n ) ) ;
Forming triangles using points on a square | Function to return the count of possible triangles ; Driver code
function noOfTriangles ( n ) { var y = 4 * n ; return ( ( y * ( y - 2 ) * ( y - 1 ) ) - ( 4 * n * ( n - 2 ) * ( n - 1 ) ) ) / 6 ; } var n = 1 ; document . write ( noOfTriangles ( n ) ) ;
Angle subtended by an arc at the centre of a circle | Function to find Angle subtended by an arc at the centre of a circle ; Driver code
function angle ( n ) { return 2 * n ; } let n = 30 ; document . write ( angle ( n ) ) ;
Check if two given Circles are Orthogonal or not | Function to Check if the given circles are orthogonal ; calculating the square of the distance between C1 and C2 ; Check if the given circles are orthogonal ; Driver code
function orthogonality ( x1 , y1 , x2 , y2 , r1 , r2 ) { let dsquare = ( x1 - x2 ) * ( x1 - x2 ) + ( y1 - y2 ) * ( y1 - y2 ) ; if ( dsquare == r1 * r1 + r2 * r2 ) return true ; else return false ; } let x1 = 4 , y1 = 3 ; let x2 = 0 , y2 = 1 ; let r1 = 2 , r2 = 4 ; let f = orthogonality ( x1 , y1 , x2 , y2 , r1 , r2 ) ; if ( f ) document . write ( " " ) ; else document . write ( " " ) ;
Check if a right | Storing all the possible changes to make the triangle right - angled ; Function to check if the triangle is right - angled or not ; Function to check if the triangle can be transformed to right - angled ; Boolean variable to return true or false ; If it is already right - angled ; Applying the changes on the co - ordinates ; Applying on the first co - ordinate ; Applying on the second co - ordinate ; Applying on the third co - ordinate ; If can 't be transformed ; Driver Code
let dx = [ - 1 , 0 , 1 , 0 ] ; let dy = [ 0 , 1 , 0 , - 1 ] ; function ifRight ( x1 , y1 , x2 , y2 , x3 , y3 ) { let a = ( ( x1 - x2 ) * ( x1 - x2 ) ) + ( ( y1 - y2 ) * ( y1 - y2 ) ) ; let b = ( ( x1 - x3 ) * ( x1 - x3 ) ) + ( ( y1 - y3 ) * ( y1 - y3 ) ) ; let c = ( ( x2 - x3 ) * ( x2 - x3 ) ) + ( ( y2 - y3 ) * ( y2 - y3 ) ) ; if ( ( a == ( b + c ) && a != 0 && b != 0 && c != 0 ) || ( b == ( a + c ) && a != 0 && b != 0 && c != 0 ) || ( c == ( a + b ) && a != 0 && b != 0 && c != 0 ) ) { return 1 ; } return 0 ; } function isValidCombination ( x1 , y1 , x2 , y2 , x3 , y3 ) { let x , y ; let possible = 0 ; if ( ifRight ( x1 , y1 , x2 , y2 , x3 , y3 ) ) { document . write ( " " ) ; return ; } else { for ( let i = 0 ; i < 4 ; i ++ ) { x = dx [ i ] + x1 ; y = dy [ i ] + y1 ; if ( ifRight ( x , y , x2 , y2 , x3 , y3 ) ) { document . write ( " " ) ; return ; } x = dx [ i ] + x2 ; y = dy [ i ] + y2 ; if ( ifRight ( x1 , y1 , x , y , x3 , y3 ) ) { document . write ( " " ) ; return ; } x = dx [ i ] + x3 ; y = dy [ i ] + y3 ; if ( ifRight ( x1 , y1 , x2 , y2 , x , y ) ) { document . write ( " " ) ; return ; } } } if ( ! possible ) document . write ( " " ) ; } let x1 = - 49 , y1 = 0 ; let x2 = 0 , y2 = 50 ; let x3 = 0 , y3 = - 50 ; isValidCombination ( x1 , y1 , x2 , y2 , x3 , y3 ) ;
Program to find Area of Triangle inscribed in N | Function to find the area of the polygon ; area of a regular polygon with N sides and side length len ; Function to find the area of a triangle ; area of one triangle in an N - sided regular polygon ; area of inscribed triangle ; Driver code
function area_of_regular_polygon ( n , len ) { let P = ( len * n ) ; let A = len / ( 2 * Math . tan ( ( 180 / n ) * 3.14159 / 180 ) ) ; let area = ( P * A ) / 2 ; return area ; } function area_of_triangle_inscribed ( n , len ) { let area = area_of_regular_polygon ( n , len ) ; let triangle = area / n ; let ins_tri = ( triangle * 3 ) ; return ins_tri ; } let n = 6 , len = 10 ; document . write ( area_of_triangle_inscribed ( n , len ) . toFixed ( 3 ) ) ;
Find the area of quadrilateral when diagonal and the perpendiculars to it from opposite vertices are given | Function to find the area of quadrilateral ; Driver code
function Area ( d , h1 , h2 ) { let area ; area = 0.5 * d * ( h1 + h2 ) ; return area ; } let d = 6 , h1 = 4 , h2 = 3 ; document . write ( " " + ( Area ( d , h1 , h2 ) ) ) ;
Find the diagonal of the Cube | Function to find length of diagonal of cube ; Formula to Find length of diagonal of cube ; Driver code ; Function call
function diagonal_length ( a ) { let L ; L = a * Math . sqrt ( 3 ) ; return L ; } let a = 5 ; document . write ( diagonal_length ( a ) . toFixed ( 5 ) ) ;
Concentric Hexagonal Numbers | Function to find nth concentric hexagon number ; Driver code ; Function call
function concentric_Haxagon ( n ) { return parseInt ( 3 * Math . pow ( n , 2 ) / 2 ) ; } var n = 3 ; document . write ( concentric_Haxagon ( n ) ) ;
Find area of the larger circle when radius of the smaller circle and difference in the area is given | Javascript implementation of the approach ; Function to return the area of the bigger circle ; Find the radius of the bigger circle ; Calculate the area of the bigger circle ; Driver code
let PI = 3.14 ; function find_area ( r , d ) { let R = d / PI ; R += Math . pow ( r , 2 ) ; R = Math . sqrt ( R ) ; let area = PI * Math . pow ( R , 2 ) ; return area ; } let r = 4 , d = 5 ; document . write ( find_area ( r , d ) . toFixed ( 2 ) ) ;
Check whether Quadrilateral is valid or not if angles are given | Function to check if a given quadrilateral is valid or not ; Check condition ; Driver code
function Valid ( a , b , c , d ) { if ( a + b + c + d == 360 ) return 1 ; return 0 ; } var a = 80 , b = 70 , c = 100 , d = 110 ; if ( Valid ( a , b , c , d ) == 1 ) document . write ( " " ) ; else document . write ( " " ) ;
Central angle of a N sided Regular Polygon | Function to calculate central angle of a polygon ; Calculate the angle ; Driver code
function calculate_angle ( n ) { var total_angle = 360 ; return total_angle / n ; } var N = 5 ; document . write ( calculate_angle ( N ) ) ;
Program to calculate the area of Kite | Function to return the area of kite ; use above formula ; Driver code
function areaOfKite ( d1 , d2 ) { var area = ( d1 * d2 ) / 2 ; return area ; } var d1 = 4 , d2 = 6 ; document . write ( " " + areaOfKite ( d1 , d2 ) ) ;
Program to calculate the area of Kite | Javascript implementation of the approach ; Function to return the area of the kite ; convert angle degree to radians ; use above formula ; Driver code
var PI = 3.14159 / 180 function areaOfKite ( a , b , angle ) { angle = angle * PI ; var area = a * b * Math . sin ( angle ) ; return area . toFixed ( 4 ) ; } var a = 4 , b = 7 , angle = 78 ; document . write ( " " + areaOfKite ( a , b , angle ) ) ;
Program to calculate angle on circumference subtended by the chord when the central angle subtended by the chord is given | JavaScript Program to calculate angle on the circumference subtended by the chord when the central angle subtended by the chord is given ; Angle on center
function angleOncirCumference ( z ) { return ( z / 2 ) ; } let angle = 65 ; let z = angleOncirCumference ( angle ) ; document . write ( " " + ( z ) + " " ) ;
Maximum and Minimum value of a quadratic function | Function to print the Maximum and Minimum values of the quadratic function ; Calculate the value of second part ; Print the values ; Open upward parabola function ; Open downward parabola function ; If a = 0 then it is not a quadratic function ; Driver Code
function PrintMaxMinValue ( a , b , c ) { var secondPart = c * 1.0 - ( b * b / ( 4.0 * a ) ) ; if ( a > 0 ) { document . write ( " " + " " + " " ) ; document . write ( " " + secondPart ) ; } else if ( a < 0 ) { document . write ( " " + secondPart + " " ) ; document . write ( " " + " " ) ; } else { document . write ( " " ) ; } } var a = - 1 , b = 3 , c = - 2 ; PrintMaxMinValue ( a , b , c ) ;
Percentage increase in the cylinder if the height is increased by given percentage but radius remains constant | javascript program to find percentage increase in the cylinder if the height is increased by given percentage but radius remains constant ; Driver code
function newvol ( x ) { document . write ( " " + " " + x + " " ) ; } var x = 10 ; newvol ( x ) ;