Escolar Documentos
Profissional Documentos
Cultura Documentos
Accin verifica()
Inicio
Leer N
Si (primo(N))
Escribir N, es primo
Sino
Escribir N, no es primo
FinSi
Fin
ACCIONES, FUNCIONES Y PREDICADOS
Predicado primo(X)
Inicio
// Si X es primo
Retornar (Verdad)
// Si X no es primo
Retornar (Falso)
Fin
Ejemplos:
A COSENO(B)
Si (A>FACTORIAL(N))
A FACTORIAL(N) + M * 2
ACCIONES, FUNCIONES Y PREDICADOS
En el caso de las funciones, el valor de retorno puede
ser de un tipo especifico: entero, real, etc. Por lo
que es necesario asignar un tipo a la funcin
correspondiente al tipo de la variable de retorno.
Ejemplo:
Funcin primo(X): Booleano
Inicio
// Si X es primo
Retornar (Verdad)
// Si X no es primo
Retornar (Falso)
Fin
ACCIONES, FUNCIONES Y PREDICADOS
Funcin Fsuma(x, y): real Accin Asuma(x, y, z)
Inicio Inicio
sx+y zx+y
Retornar (s) Fin
Fin
Accin Suma()
Inicio
Leer n1
Leer n2
Escribir Fsuma(n1, n2)
Asuma(n1, n2, n3)
Escribir n3
Fin
TRATAMIENTOS Y RESULTADO
Repetir
Tratamiento
Hasta (condicin)