- Get link
- X
- Other Apps
- Get link
- X
- Other Apps
Code:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Demo Number and its Squares</title>
</head>
<body>
<script type="text/javascript">
var num=prompt("Enter a Number: \n","");
var msgstr;
if(num>0&&num!=null){
msgstr="Number and its Square are \n";
for(i=1;i<=num;i++)
{
msgstr=msgstr +i+ "^2="+i*i+"\n";
}
alert(msgstr);
}
</script>
</body>
</html>
Output:
- Get link
- X
- Other Apps

