martes, 7 de marzo de 2017

Código y ordinograma de un programa que pide 2 números y me dice el mayor, menor o iguales

Programa que pide dos números por pantalla y me dice cual de esos dos números, es mayor, cual es menor o si son iguales


ORDINOGRAMA

                                                         INICIO
                                                               |
                                                               |
                                                 Declarar variables
                                                            A, B
                                                               |
                                                               |
                                                      Leer A y B
                                                               |
                                                               |
                                                        A==B______________S_______
                                                              |                                           |
                                                              |                                           |
                                                              |                                           |
                                                              N                                  Son iguales
                                                              |                                             |
                                                              |                                             |
                                                         A>B-------- S                                |
                                                              |             |                                |
                                                              |             |                                |
                                                             N           A,B                             |
                                                             |               |                                |
                                                             |               |                                |
                                                           B,A            |                                |
                                                             |------|-----|                                  |
                                                                      |                                       |
                                                                 |-- -|---------------------------------------|
                                                                                         |
                                                                                         |
                                                                                       FIN


CÓDIGO

var a;
var b;
a=prompt('Ingrese primer número');
b=prompt('Ingrese segundo número');
a=parseInt(a);
b=parseInt(b);
    if(a==b){
document.write('son iguales');
}
else{
if(a>b){
document.write(a,'>',b);
}
else{
document.write(b,'>',a);
}
}


OTRO CÓDIGO
 <html>
    <head>
    </head>
    <body>
            <script type="text/javascript">
        var a;
        var b;  
            a =prompt('Ingrese primer número:','');
            b =prompt('Ingrese segundo número:','');
            a=parseInt(a);
            b=parseInt(b);
            if(a==b){
            document.write('Son iguales');
            }
            else{
            if(a>b){
                document.write(a,'>',b);
            }
            else{
            document.write(b,'>',a);
            }
        }
            </script>
    </body>

</html>


No hay comentarios:

Publicar un comentario