leonardothe32k
Usuario (Ecuador)
• programa que permite calcular el digito verificador de la cedulaCódigo (index.html) <html><head><meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /><title>DIGITO VERIFICADOR DE LA CEDULA</title><style type="text/css"><!--.Estilo1 { color: #003399; font-weight: bold;}--></style></head><body><form action="cedula.php" method="post" name="form1" target="_parent" id="form1"> <table width="272" border="1" align="center"> <tr> <td colspan="2"><div align="center"><span class="Estilo1">Digito Verificador de la Cedula </span></div></td> </tr> <tr> <td width="117">Cedula :</td> <td width="139"><input name="txtdig" type="text" id="txtdig" size="15" maxlength="9" /></td> </tr> <tr> <td><label> <input type="submit" name="Submit" value="Calcular Digito" /> </label></td> <td><label> <input type="reset" name="Submit2" value="Restablecer" /> </label></td> </tr> </table></form></body></html>Código (Cedula.php) <html><head><meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /><title>DIGITO VERIFICADOR DE LA CEDULA</title></head><body><?php$ced=$_POST['txtdig'];$sp=0;$si=0;$st=0;$dig=0; for($i=0;$i<10;$i=$i+2) { $aux=$ced[$i]*2; if($aux>9) { $aux=$aux-9; } $si=$si+$aux; } for($i=1;$i<=8;$i=$i+2) { $sp=$sp+$ced[$i]; } $st=$sp+$si; $a=$st/'10'; $dig=((int)($st/10)+1)*10; $dv=$dig-$st; if($dv=='10') { $dv=0; }?><table width="306" height="132" border="1" align="center"> <tr> <td colspan="2"><div align="center"><strong>Cedula</strong></div></td> </tr> <tr> <td width="195">Cedula : </td> <td width="95"><?php echo $ced?></td> </tr> <tr> <td>Digito : </td> <td><?php echo $dv?></td> </tr></table></body></html>Un Programa el cual perimitira calcular el digito verificador de la cedula en php
Suma de dos números<?php $a=10;$b=10;$suma =$a+$b;echo $suma?> Numero mayor<?php $a=10;$b=10;If ($a<$b) { echo “$a es mayor’” }else { echo “$b es mayor’” }?> Ejercicio While<?php $a=1;While ($a<=10) { echo $a; $a=$a+1; }?> Ejercicio For<?php For ($i=1; $i <=10; $i++) { echo “<br>”. $i; }?> Ejercicio If<?php $i=15;If ($i>=’18’) { echo “mayor de edad”; }Else { echo “menor de edad”; }?> • Programa que despliega los 10 primeros númerosCódigo en php utilizando while<html><head><meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /><title>Documento sin título</title></head><body> <?php // declaracion de variables con el signo $ /* comentario parafo */ $numero=1; while($numero<=10) { echo"<br>".$numero; $numero++; } ?></body></html> • Programa que permite verificar si una persona es mayor de edadCódigo en php utilizando if<html><head><meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /><title>Documento sin título</title></head><body><?php $ed=12; if($ed>='18') { echo "Es Mayor de Edad y Tiene $ed años"; } else { echo "Es Menor de Edad y Tiene $ed años"; }?></body></html> • Programa que despliega los 10 primeros númerosCódigo en php utilizando for<html><head><meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /><title>Documento sin título</title></head><body><?php for($i=1; $i<=10;$i++) { echo"$i <br>"; }?></body></html> • Programa que permite sumar dos númerosCódigo en php utilizando operadores aritméticos<html><head><meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /><title>Documento sin título</title></head><body><?php$a=4;$b=5;$suma=$a+$b;echo " la suma es $suma";?></body></html>
• Programa para obtener la serie de fibionacciCódigo (index.html) <html><head><meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /><title>Serie de Fibonaci</title></head><body><form id="form1" name="form1" method="post" action="fibonaci.php"> <label> <input name="txtnum" type="text" id="txtnum" /> </label> <p> <label> <input type="submit" name="Submit" value="Enviar" /> </label> <label> <input type="reset" name="Submit2" value="Restablecer" /> </label> </p></form></body></html>Código (fibonaci.php)<html><head><meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /><title>Serie de Fibonaci</title></head><body><?php $aux=$_POST['txtnum']; $a=1; $b=1; $c=$a+$b; for($i=1;$i<=$aux;$i++) { echo "<br>".$c; $a=$b; $b=$c; $c=$a+$b; }?></body></html>