miércoles, 4 de noviembre de 2009

Código Funciones Y Hola Mundo

HOLA MUNDO
Este programa despliega por pantalla el texto “Hola Mundo”
PUBLIC SUB Main()
PRINT "Hola mundo"
END
FUNCIONES
En este programa utilizamos dos módulos el pricipal (MMain) y modulo 1, Calcula las operaciones
básicas suma, resta, multiplicación y división.
MMain
PUBLIC SUB Main()
DIM a, b AS Integer
PRINT "<<<>>>"
PRINT "Ingrese primer valor"
INPUT a
PRINT "Ingrese segundo valor"
INPUT b
PRINT opera(a, b)
PRINT opera1(a, b)
PRINT opera2(a, b)
PRINT opera3(a, b)
END
'funcion para sumar
PUBLIC FUNCTION opera(v1 AS Integer, v2 AS Integer) AS Integer
DIM suma AS Integer
suma = v1 + v2
PRINT "La suma es..."
RETURN suma
END
'funcion para restar
PUBLIC FUNCTION opera1(v1 AS Integer, v2 AS Integer) AS Integer
DIM resta AS Integer
resta = v1 - v2
PRINT "La resta es.."
RETURN resta
END
'funcion para multiplicar
PUBLIC FUNCTION opera2(v1 AS Integer, v2 AS Integer) AS Integer
DIM mult AS Integer
mult = v1 * v2
PRINT "La multiplicacion es..."
RETURN mult
END
'funcion para dividir
PUBLIC FUNCTION opera3(v1 AS Integer, v2 AS Integer) AS Integer
DIM divs AS Integer
divs = v1 DIV v2
PRINT "la division es..."
RETURN divs
END
modulo1
' Gambas module file
'funcion para sumar
PUBLIC SUB main()
DIM a, b AS Integer
PRINT "primer valor"
INPUT a
PRINT "sugundo valor"
INPUT b
PRINT "La suma es...", modulo1.suma(a, b)
PRINT "La resta es...", modulo1.resta(a, b)
PRINT "La multiplicacion es...", modulo1.multiplicacion(a, b)
PRINT "La division es...", modulo1.division(a, b)
END

No hay comentarios:

Publicar un comentario