15 points
please help me in this question...
Number 3
Attachments:
Answers
Answered by
5
Hey there!
----------
⇒ Using While Loop :
<HTML>
<HEAD>
<TITLE>Sum of Series</TITLE></HEAD>
<BODY>
<H1>Sum of Series</H1>
<SCRIPT Language="Javascript" TYPE="text/javascript">
var sum=0
var i=1
while(i<=20)
{
sum=sum+i
i+=3
}
document.write("Sum of Series = " +sum)
</SCRIPT>
</BODY>
</HTML>
→ Using Do-While Loop :
<HTML>
<HEAD>
<TITLE>Sum of Series</TITLE></HEAD>
<BODY>
<H1>Sum of Series</H1>
<SCRIPT Language="Javascript" TYPE="text/javascript">
var sum=0
var i=1
do {
sum=sum+i
i+=3
} while(i<=20)
document.write("Sum of Series = " +sum)
</SCRIPT>
</BODY>
</HTML>
Similar questions