EJERCICIO N 01 REALICE UN PROGRAMA QUE IMPRIMA DEL 1

Anuncio
EJERCICIO N 01
REALICE UN PROGRAMA QUE IMPRIMA DEL 1 AL 20 USANDO DO WHILE LOOP
Dim i, a, s, Integer
i=1
Do While i< 20
i=i+1
TextBox2.Text = i
Loop
CODIFICACION
Public Class Form1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles
Button1.Click
Dim i As Integer
i=0
Do While i <= 20
TextBox1.Text = i
i=i+1
Loop
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles
Button2.Click
TextBox1.Text = " "
End Sub
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles
Button3.Click
End
End Sub
End Class
EJERCICIO 02
FACTORIAL DE UN NUMERO
Dim i, n, al AsInteger
n = TextBox1.Text
i=1
al = 1
DoWhile i <= n
al = al * i
i=i+1
Loop
TextBox2.Text = al
EndSub
TextBox1.Text = " "
TextBox2.Text = " "
End
EJERCICIO N 03
INGRESAR N NUMEROS Y CUANTOS PARES EXISTEN
PrivateSub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles
Button1.Click
Dim a, b, i, n, c AsInteger
i=0
a = TextBox1.Text
c=0
DoWhile i <= a
i=i+1
n = Val(TextBox2.Text)
b = n Mod 2
If b = 0 Then
c=c+1
EndIf
Loop
TextBox3.Text = c
EndSub
PrivateSub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles
Button2.Click
TextBox1.Text = ""
TextBox2.Text = ""
TextBox3.Text = ""
EndSub
EJERCICIO N 05
Suma de factorial
PrivateSub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles
Button1.Click
Dim i, n, j, sum, al AsInteger
n = TextBox1.Text
i=1
al = 1
sum = 0
j=1
DoWhile i <= n
DoWhile j <= i
al = al * j
j=j+1
Loop
sum = sum + al
i=i+1
Loop
TextBox2.Text = sum
TextBox1.Text = " "
TextBox2.Text = " "
End
Descargar