Latest Movie :
Home » » Calculator, For Statement

Calculator, For Statement

{[['']]}
Write Code: javascript

<script type="text/javascript">

var total = 0;

var even = 0;

for ( x = 1, y = 1; x <= 100; x++, y++ ) {

if ( ( y % 2 ) == 0 ) {

even = even + y;

}

total = total + x;

}

document.write ( "The total sum: " + total + "<br>");

document.write ( "The sum of even values: " + even );

</script>

</head>

<body>

Output:
The total sum: 5050
The sum of even values: 2550
Share this article :
 
Support : Creating Website | Johny Template | Mas Template
Copyright © 2011. isophal.com - All Rights Reserved
Template Created by Creating Website Published by Mas Template
Proudly powered by Blogger