<html>
<head>
<script type = "text/javascript">
var num = window.prompt("Enter the number:","");
var n = parseInt(num);
result = sumnaturalno(n);
window.alert("The sum of " + n + "natural number is" + result);
function sumnaturalno(n)
{
var i;
var sum = 0;
for(i = 1;i <= n; i++){
sum = sum + i;}
return (sum);
}
</script>
</head>
</html>
<head>
<script type = "text/javascript">
var num = window.prompt("Enter the number:","");
var n = parseInt(num);
result = sumnaturalno(n);
window.alert("The sum of " + n + "natural number is" + result);
function sumnaturalno(n)
{
var i;
var sum = 0;
for(i = 1;i <= n; i++){
sum = sum + i;}
return (sum);
}
</script>
</head>
</html>
That was very helpful java code
ReplyDeleteThanks for sharing
Get training on digital marketing training with our industrial experts in
seo training in bangalore join today
Write a javascript code embeded in HTML that computes the sum of even numbers in the range 50 to
ReplyDelete100 and display the results on the screen
Write a HTML code embedded with a javascript function that will add the values 30 and 20 display the
ReplyDeleteoutput
Write an ASP program embedded on HTML that would be used to display all the multiples of 5 in the
ReplyDeleterange 1 and 50.
Write a HTML code embedded with a javascript function that will add the values 30 and 20 display the
ReplyDeleteoutput
javascript code examples script examples for starters
ReplyDeleteUsing JavaScript, accept 5 numbers from the user & display the sum of all array elements
ReplyDeleteWrite java script programme to calculate the sum of 1st 10 natural numbers
ReplyDeleteWrite a JavaScript function to find sum of first 20 even natural numbers
ReplyDeleteThanks for the information about Blogspot very informative for everyonefullstack python classes in pune
ReplyDelete