bucle for
Ejemplos de bucles FOR
-----------------------------------------------------
Factorial de un numero
Dim a, x As Long
Dim f As Integer=1
Console.Write("numero :")
a = Console.ReadLine
Console.WriteLine("su factorial:")
For x = 1 To a
f = f * x
Next
Console.WriteLine(f)
Console.Read()
-------------------------------------------------------
Divisores de un numero
Dim a, x As Integer
Console.Write("numero :")
Console.Write("")
a = Console.ReadLine
Console.WriteLine("divisores:")
For x = 1 To a
If (a Mod x) = 0 Then
Console.WriteLine(x)
End If
Next x
Console.Read()
---------------------------------------------------------
-----------------------------------------------------
Factorial de un numero
Dim a, x As Long
Dim f As Integer=1
Console.Write("numero :")
a = Console.ReadLine
Console.WriteLine("su factorial:")
For x = 1 To a
f = f * x
Next
Console.WriteLine(f)
Console.Read()
-------------------------------------------------------
Divisores de un numero
Dim a, x As Integer
Console.Write("numero :")
Console.Write("")
a = Console.ReadLine
Console.WriteLine("divisores:")
For x = 1 To a
If (a Mod x) = 0 Then
Console.WriteLine(x)
End If
Next x
Console.Read()
---------------------------------------------------------
Tabla de multiplicar de un numero
Dim n, x, p As Integer
Console.Write("Ingrese numero entero: ")
n = Console.ReadLine
For x = 1 To 12
p = n * x
Console.WriteLine(x & "*" & x & "=" & p)
Next
Console.Read()
Comentarios