0% found this document useful (0 votes)
24 views3 pages

Código Secuencial Y Estructurado en C++

The document contains code examples in C++, BASIC, and Visual Basic that demonstrate sequential and structured programming to perform basic math operations. The C++ and BASIC examples declare variables, read in operands, perform addition, subtraction, multiplication and division calculations sequentially, and output the results. The Visual Basic example uses a graphical user interface with buttons to trigger event handler subroutines for each operation, which read operands, perform the calculation, and output the result to a text box.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
24 views3 pages

Código Secuencial Y Estructurado en C++

The document contains code examples in C++, BASIC, and Visual Basic that demonstrate sequential and structured programming to perform basic math operations. The C++ and BASIC examples declare variables, read in operands, perform addition, subtraction, multiplication and division calculations sequentially, and output the results. The Visual Basic example uses a graphical user interface with buttons to trigger event handler subroutines for each operation, which read operands, perform the calculation, and output the result to a text box.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

CDIGO SECUENCIAL Y ESTRUCTURADO EN C++

#include <iostream>
using namespace std;

int main(int argc, char *argv[])


{
//Declarar variables
double operandoA, operandoB, division;
double suma, resta, multiplicacion;
//Leer operandos
cout<<"\nIntroducir operandos:\n";
cin>>operandoA;
cin>>operandoB;
//Operaciones
suma = operandoA + operandoB;
resta = operandoA - operandoB;
multiplicacion = operandoA * operandoB;
division = operandoA / operandoB;
//Mostrar resultados
cout<<"\n********* RESULTADOS ************";
cout<<"\n\tSuma: "<<suma;
cout<<"\n\tResta: "<<resta;
cout<<"\n\tMultiplicacion: "<<multiplicacion;
cout<<"\n\tDivision: "<<division<<"\n\n";
system("PAUSE");
return 0;
}
CDIGO SECUENCIAL Y ESTRUCTURADO EN BASIC

Module Module1
Sub Main()
'Operandos
Dim OperandoA As Double, OperandoB As Double
Dim Suma As Double, Resta As Double
Dim Multiplicacion As Double, Division As Double
'Leer valores para los operandos
Console.WriteLine(vbCrLf & "Introducir operandos:")
OperandoA = Double.Parse(Console.ReadLine())
OperandoB = Double.Parse(Console.ReadLine())
'Procesar operaciones
Suma = OperandoA + OperandoB
Resta = OperandoA - OperandoB
Multiplicacion = OperandoA * OperandoB
Division = OperandoA / OperandoB
'Mostrar resultados
Console.WriteLine(vbCrLf & "********* RESULTADOS ************" _
& vbCrLf & vbTab & "Suma: " & Suma _
& vbCrLf & vbTab & "Resta: " & Resta _
& vbCrLf & vbTab & "Multiplicacin: " & Multiplicacion _
& vbCrLf & vbTab & "Divisin: " & Division _
& vbCrLf & vbCrLf & _
"*********************************")
'Detener pantalla
Console.ReadLine()
End Sub
End Module
CDIGO ORIENTADO A EVENTOS VISUAL BASIC

Public Class Form1


'Variables para leer operandos
Dim OperandoA As Double, OperandoB As Double
'Subrutina leer operandos
Private Sub LeerOperandos()
OperandoA = Double.Parse(txtOperandoA.Text)
OperandoB = Double.Parse(txtOperandoB.Text)
End Sub
'Evento del botn para sumar
Private Sub Sumar_Click(sender As Object, e As EventArgs) _
Handles Sumar.Click
Dim Suma As Double
LeerOperandos()
Suma = OperandoA + OperandoB
txtResultado.Text = Suma.ToString
End Sub
'Evento del botn para restar
Private Sub Restar_Click(sender As Object, e As EventArgs) _
Handles Restar.Click
Dim Resta As Double
LeerOperandos()
Resta = OperandoA - OperandoB
txtResultado.Text = Resta.ToString
End Sub

'Evento del botn para multiplicar


Private Sub Multiplicar_Click(sender As Object, e As EventArgs) _
Handles Multiplicar.Click
Dim Multiplicacion As Double
LeerOperandos()
Multiplicacion = OperandoA * OperandoB
txtResultado.Text = Multiplicacion.ToString
End Sub
'Evento del botn para dividir
Private Sub Dividir_Click(sender As Object, e As EventArgs) _
Handles Dividir.Click
Dim Division As Double
LeerOperandos()
Division = OperandoA / OperandoB
txtResultado.Text = Division.ToString
End Sub
End Class

You might also like