Q:

Write A JavaScript That Calculates The Squares And Cubes Of The Numbers From 0 To 10 And Outputs XHTML Text That Displays The Resulting Values In An XHTML Table Format, As Follows: Number Square Cube

belongs to collection: HTML + Javascript Examples

0

Write A JavaScript That Calculates The Squares And Cubes Of The Numbers From 0 To 10 And Outputs XHTML Text That Displays The Resulting Values In An XHTML Table Format, As Follows: Number Square Cube 

0 0 0 
1 1 1 
2 4 8 
3 9 27 
4 16 64 
5 25 125 
6 36 216 
7 49 343 
8 64 512 
9 81 729 
10 100 1000 

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

<html>
<head> 
<script> 
document.write( "<table> <tr> <th>Number</th> <th>Square</th> <th>Cube</th> </tr>" ) 
for(var n=0; n<=10; n++) 
{ 
document.write( "<tr><td>" + n + "</td><td>" + n*n + "</td><td>" + n*n*n + "</td></tr>" ) 
} 
document.write( "</table>" ) 
</script> 
</head> 
</html>

 

Output:

Number Square Cube
0 0 0
1 1 1
2 4 8
3 9 27
4 16 64
5 25 125
6 36 216
7 49 343
8 64 512
9 81 729
10 100 1000

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

This question belongs to these collections

Similar questions


need a help?


find thousands of online teachers now
Write A Program That Inputs An Encrypted Four-Digi... >>
<< Build A Simple Calculator Using HTML Form Elements...