hercioneto

PW1 2019 - calculadora.php

Sep 10th, 2019
331
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.62 KB | None | 0 0
  1. <?php
  2. //calculadora.php
  3.  
  4. function somar($n1,$n2) {
  5.     $resultado = $n1 + $n2;
  6.     return $resultado;
  7. }
  8. function subtrair($n1,$n2) {
  9.     $resultado = $n1 - $n2;
  10.     return $resultado; 
  11. }
  12. function multiplicar($n1,$n2) {
  13.     $resultado = $n1 * $n2;
  14.     return $resultado;
  15. }
  16. function dividir($n1,$n2) {
  17.     $resultado = $n1 / $n2;
  18.     return $resultado;
  19. }
  20.  
  21. function imprimir($texto) {
  22.     echo "<div> $texto </div>";
  23. }
  24. /*
  25. $a = 5;
  26. $b = 2;
  27. $mais = somar($a,$b);
  28. $menos = subtrair($a,$b);
  29. $vezes = multiplicar($a,$b);
  30. $dividido = dividir($a,$b);
  31.  
  32.  
  33. imprimir($mais);
  34. imprimir($menos);
  35. imprimir($vezes);
  36. imprimir($dividido);
  37. */
  38. ?>
Advertisement
Add Comment
Please, Sign In to add comment