write JavaScript code to print square of accepted number using function
Answers
Answered by
14
Code:-
var x = prompt("Enter number : ");
var sq = Math.pow(x, 2);
document.write(sq);
Hope this is the correct code for your use....
Answered by
4
The java script code for the above is as follows:
Explanation:
<! –– SCRIPT WORD WRITTEN IN "<>" SYMBOLS ––>
var number = prompt("Enter the number to find the square of that number"); // it is used to take the inputs from the user.
document.write(number*number); // it is used to print the square of the number.
<! –– SCRIPT WORD WRITTEN IN "</>" SYMBOLS ––>
Output:
- If the user inputs 5, then the output is 25.
- If the user inputs 6, then the output is 36.
Code Explanation:
- The above code is in the javascript language.
- The first line of the code is used to take the inputs from the user.
- The second line of the code is used to print the square of the number.
Learn More:
- Java script code : https://brainly.in/question/14600133
Similar questions