Write a program to get 10 student mark from user and sort it in ascending order
Example :
<title>Write a program to get 10 student mark from user and sort it in ascending order</title>
<?php
/* Write a program to get 10 student mark from user and sort it in ascending order. */
$n=array(2,1,5,6,4,3,0,8,9,7);
for($a=0;$a<=9;$a++)
{
for($b=$a+1;$b<=9;$b++)
{
if($n[$a]>$n[$b])
{
$temp=$n[$a];
$n[$a]=$n[$b];
$n[$b]=$temp;
}
}
}
print"Asending Number";
for($a=0;$a<10;$a++)
{
print"<br>".$n[$a];
}
?>
No comments:
Post a Comment