ទំព័រដែលថ្មីៗ

Sunday, December 8, 2013

Do … While

                          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

ស្វែងរក

 


MOM TENG
(Web Master , Designer , Journalist , and Video Editor )
Student of Social Communication and Journalism 2nd Generation and 2nd year in
Don Bosco Vocational Center Kep
Email : tengmom20@gmail.com , tengmom20@yahoo.com , tengmom20@hotmail.com , Tel :070286200
Skype : tengmom.donbsco.com , Twitter : momteng , Facebook : តេងវិជ្ជា ដុនបូស្កូ, Google+ : mom teng
My Another Website : cambodian1.wordpress.com , khmernowaday.blogspot.com, cambodianteng.blogspot.com/, My picasa , donboscoke.org
Youtube : My Videos
Address : Thmey Village , Prey Thom Commune , Kep City , Kep Province , Cambodia .
Thank!!!!!