Tuesday, April 23, 2013


Armstrong Number Program -- Source Code -- Logic programs
<html>
<head><TITLE></TITLE>
<script language="JavaScript">
var b,z,c=0;
var a=prompt("Enter a number");
z=a;
while(z>0)
{
b=z%10;
c=c+(b*b*b);
z=parseInt(z/10);
}
if(a==c)
alert("given no is amstrong number");
else
alert("given no is not an amstrong number");
</script>
</head>
<body></body>
</html>


/**********************************<br>

<html>
<head><TITLE></TITLE>
<script language="JavaScript">
var b,z,c=0;
//var a=prompt("Enter a number");
//z=a;
for(i=150;i<10000;i++)
{

z=i;
c=0;
while(z>0)
{
b=z%10;
c=c+(b*b*b);
z=parseInt(z/10);
}
if(i==c)
alert("given no is amstrong number"+i);
}
</script>
</head>
<body></body>
</html>

******************************************/

0 comments:

Post a Comment