Tuesday, April 23, 2013


Reverse OF A Number program code and Reverse OF A String program source code

Reverse OF A Number
<html>
<head><TITLE></TITLE>
<script language="JavaScript">
var a=prompt("Enter a value");
var b,sum=0;
var z=a;
while(a>0)
{
b=a%10;
sum=sum*10+b;
a=parseInt(a/10);
}
alert(sum);
</script>
</head>
<body></body>
</html>

Reverse Of A String 

<html>
<head><TITLE></TITLE>
<script language="JavaScript">
var a=prompt("Enter a string");
var b='';
sum=0;
var z=a.length;
alert("Length:"+z)

for(i=z-1;i>=0;i--)
{
b+=a[i];
}
alert("Reverse of a Number"+a+"is:"+b);
</script>
</head>
<body></body>
</html>

0 comments:

Post a Comment