java script
Prime or No:
<html><style>
body
{
background-color: #a3d5d3;
}
</style>
<script type="text/javascript">
var a=prompt("enter a number to check prime or not");
if (a%2==0)
{
alert(a+" is a Prime number");
}
else
{
alert(a+" is not a Prime number");
}
</script>
</html>
Bubble sort:
<html><style>
body
{
background-color:#a3d5d3;
}
</style>
<h1 align= center>Bubble Sort</h1>
<script>
var a=[10,9,8,];
for(var i=1;i<a.length;i++)
{
for(var j=0;j<a.length;j++)
if(a[j]>a[j+1])
{
var temp=a[j];
a[j]=a[j+1];
a[j+1]=temp;
}
}
document.write(a);
</script>
</html>

Comments
Post a Comment