Programación y Método Numérico
Ejercicios Prácticos de Programación en Visual Basic y Excel
Unidad 7: Calcular el seno (x) en Visual Basic
#incluide “stafx.h”
#incluide <iostream>
#incluide <math.h>
Using std :: cin;
Using std :: cout;
Using std :: endl;
Int_tmain (int argc, _tchar * argv)
{
Whi (true) {
Long doublé x= 0, fat, sen=0, y=0;
Int N= 0, i= 0, u=0, sig=-1;
Doublé a = 0, b = 0;
Fact= 1;
Cout<< “ingrese el número de repeticiones” <<endl; cin >> x;
x= x+ 3.141618/ 180;
sen= x ;
doublé base = 0, exponente = 0, potencia = 0, potenciaz = 0;
for (i = 2; ic = N ; i ++){
fact = fact * (2 * i-1) * (2*i-2);
u= (2* i-1);
b = pow (x,u);
sen = sen + ((sig)*b) / fat ;
sig = -sig ;
}
Cout << “seno (x) calculado = “<<sencc endl ;
Cout << “seno (x) teorico = <<sin (x) << endl ;
Y= (sin (x) –sen ) / sin (x)
Cout<< “el valor absoluto (%) = “<<abs (y*100) <<endl ;
Cout<< “está perfecto ponga 5” <<endl ;
}
Return 0,
}
Unidad 6: Ejemplifique varias diagonales sucesivas a través de la acumulación de texto, con datos introducidos por teclado.
Private Sub CommandButton1_Click ()
Dim i As Interger
Dim j As Interger
Hoja1.Cells (1, 1) = "DICIEMBRE"
For i = 2 To 8
For j = 1 To i
If ((i + j) Mod 2) = 0 Then
Hoja1.Cells (i, j) = Hoja1. Cells (1, 1)
End If
Next j
Next i
End sub
Dim i As Interger
Dim j As Interger
Hoja1.Cells (1, 1) = "DICIEMBRE"
For i = 2 To 8
For j = 1 To i
If ((i + j) Mod 2) = 0 Then
Hoja1.Cells (i, j) = Hoja1. Cells (1, 1)
End If
Next j
Next i
End sub
No hay comentarios:
Publicar un comentario