We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
Day 1: Let and Const
Day 1: Let and Const
+ 0 comments Could any one please tell me the concept about readLine(). How can we use in Visual Studios, or any other editor to take dyinamic values from the user
+ 0 comments const PI = Math.PI; const illigal = 'Illegal r value'; let checkRadius = function(r) { if (r > 0 && r <= 100 && r !== NaN) return true; return false; } let circleArea = function(r) { if (checkRadius(r)) return PI * r * r; return illigal; } let circlePerimeter = function(r) { if (checkRadius(r)) return 2 * PI * r; return illigal; } function main() { // Write your code here. Read input using 'readLine()' and print output using 'console.log()'. let r = Number.parseFloat(readLine()).toFixed(3); // r refers to radius // Print the area of the circle: console.log(circleArea(r)); // Print the perimeter of the circle: console.log(circlePerimeter(r));
+ 0 comments JS Solution
const PI=Math.PI; let r=readLine(); console.log(PI*r**2); console.log(2*PI*r);
+ 0 comments const PI = Math.PI const r = readLine() // Print the area of the circle: console.log(PI*r**2) // Print the perimeter of the circle: console.log(2*PI*r)
+ 0 comments function main() { const PI=Math.PI // Print the area of the circle: let r=readLine() console.log(PI*r*r) // Print the perimeter of the circle: console.log(2*PI*r)
Load more conversations
Sort 186 Discussions, By:
Please Login in order to post a comment