i. Do
… While
Do… while loop ជាដំបូងវាដំណើរការនូវកូដនោះ
បន្ទាប់មកទើបវាធ្វើការត្រួតពិនិត្យទៅលើ លក្ខខណ្ឌ ហើយវានិងដំណើរឡើងវិញរហូត
រហូតដល់លក្ខខណ្ឌលែងពិត។
Syntax:
Do
{
កូដដែលត្រូវដំណើរការ
}
While(condition is true)
N
|
1
|
code
|
<form method="post" target="_self">
Start:<input
type="text" name="start" value=<?php echo
$_POST["start"] ?>>
End:<input type="text" name="end"
value=<?php echo $_POST["end"] ?>>
<input type="submit" name="btnsub"
value="Process" >
</form>
<table border="1">
<tr>
<td>N</td>
<td>Sin(N)</td>
<td>Cos(N)</td>
<td>TAN(N)</td>
<?php
$start=empty($_POST["start"])?"":$_POST["start"];
$end=empty($_POST["end"])?"":$_POST["end"];
$loop=$start;
do{
echo"<tr>
<td>
".$loop."
<td>
".sin(pi()/180*$loop)."
<td>
".cos(pi()/180*$loop)."
<td>"
.tan(pi()/180*$loop);
$loop++;
}while($loop<=$end);
?>
</table>
|
Result
|
|
|
2
|
Code
|
<form method="post"
target="_self">
Value:<input
type="text" name="txtv" value="<?php echo
$_POST["txtv"];?>"/>
<input type="submit"
name="btnv" value="sum series" />
</form>
<?php
$val=empty($_POST["txtv"])?"":$_POST["txtv"];
$loop=1;
$total="";
do{
if($loop==$val)
echo
$loop."=";
else
echo
$loop."+";
$total=$total+$loop;
$loop++;
}while($loop<=$val);
echo
$total;
?>
|
Result
|
|
0 សូមធ្វើការតំលៃផង:
Post a Comment