Sort by

recency

|

202 Discussions

|

  • + 0 comments
    function main() {
        // Write your code here. Read input using 'readLine()' and print output using 'console.log()'.
        const PI = Math.PI
        let r = parseFloat(readLine());
        
        // Print the area of the circle:
        let area;
        area = PI * r * r
        console.log(area)
        
        // Print the perimeter of the circle:
        let perimeter;
        perimeter = 2 * PI * r
        console.log(perimeter)
    
  • + 0 comments

    My easy solutiion for the beginners PI should be in capital in the whole code dont make the mistake. I made it Once I chnaged it to Uppercase it fixed the error. const PI = Math.PI; const r = readLine(); const area = PI*r*r; console.log(area); const perimeter = 2 * PI * r; console.log(perimeter);

  • + 0 comments

    is this little bit stricky question but easy before i did understand i try to access r from parameter , i that simple i should to just access r from readline() input fucntion then used into mine code

    const r = Readline(); const PI = Math.PI;

    const area = Pi *( r * r ); console.log(area);

    const perimeter = 2 * PI * r; console.log(perimeter);

  • + 0 comments

    THIS IS MINE:

    const PI = Math.PI, r = parseFloat(readLine());
        
        console.log(PI * r ** 2);
        console.log(2 * PI * r);
    
  • + 0 comments

    try {
    // Attempt to redefine the value of constant variable PI PI = 0; // Attempt to print the value of PI console.log(PI); } catch(error) { console.error("You correctly declared 'PI' as a constant."); } this try causing additional console as 0 and leading to wrong answer what i can do