You are on page 1of 11

EJERCICIOS DE SMALL

BASIC
11-20
CONTINUACION DE LOS EJERCICIOS DE SMALL BASIC
MARLON ADALBERTO URRUTIA DUARTE
5TO. PAE B

11) Pida al usuario dos nmeros enteros (que se guardaran en las variables NUM 1 Y NUM 2). Si
num 2 es cero deber mostrar mensaje de error , en caso contrario mostrara el residuo dela
divisin de num1 y num 2.
inicio

1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.

Inicio
Num1 = 0, numb2= 0, resto =0
Ingrese primer numero
Ingrese segundo numero
Si numb2 es igual al cero
Visualizar mensaje ingrese numero que no sea cero
Regresar a paso 4
Fin del si
R = al residuo de la divisin
Visualizar resto
Fin

Numb1=0,numb2=0,resto=0

Ingrese primer numero

Ingrese segundo numero

Si
num2=0
entonces

si

Visualizar mensaje de error


ingrese nmero que no
sea cero

R= al residuo de la division

Visualizar resto

fin

Programa:
TextWindow.WriteLine ("Ingrese primer nmero")
Num 1 = TextWindow.Read ()
Regresar:
TextWindow.WriteLine ("Ingrese segundo nmero")
Num 2 = textwindow.Read ()
If num2=0 Then
TextWindow.WriteLine ("ERROR, INGRESE UN NUMERO QUE NO SEA CERO")
Goto Regresar
EndIf
residuo=math.Remainder(num1,num2)
TextWindow.WriteLine ("El resto de la divisin es: "+residuo)

no

12) Pida al usuario un nmero entero, diga si es par o impar, y repita todo lo anterior hasta que
el nmero que se introduzca sea 0. (Nota: para saber si un nmero es par, se mira si el resto de
su divisin entre 2 es 0).
inicio
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.

Inicio
N = 0, resto= 0
Introduzca un numero
Si numero es 0 fin
De lo contrario
R= residuo de n/2
Si r = 0
Visualizar numero es par
De lo contrario
Visualizar numero es impar
Fin del si
Fin

Ingrese primer numero

Si n =
0 fin

si

no
R = al residuo de
la division

regresar:
TextWindow.WriteLine ("ingres primer numero")
n= textwindow.read()

Si resto=
0
entonces

residuo = Math.Remainder (n,2)


If n= 0 Then

si

Goto end

Numero es par

elseIf residuo = 0 Then


TextWindow.WriteLine ("numero es par")

Numero es impar

Else
TextWindow.WriteLine ("numero es impar")
EndIf
Goto regresar
end:

fin

no

13) pida al usuario veinte nmeros y muestre su suma en pantalla.

1.
2.
3.
4.
5.
6.
7.
8.

Inicio

Para i = 1, c = 0, p = 0

Inicio
Para I =1, c =0, p =0
Para i = 1 hasta20
Ingrese un numero + i
P=i+c
Fin del para
Visualizar p
Fin

Para i =
1 hasta
20

no

insertar un numero + i

For i = 1 To 20
TextWindow.WriteLine ("ingrese un numero "+i)

P=p +c

c = TextWindow.Read ()
p = p+ c

visualizar resultado

EndFor
Fin

TextWindow.WriteLine ("la suma total es: " + p)

si

14) Pida al usuario veinte nmeros reales y muestre cual es el mayor de ellos y cual el menor.

inicio

1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13.

Inicio
My = 0, mn= 999999999, i = 1
Ingrese 20 numeros
Para i = 1 hasta 20
Visualizar ingrese el numero + i
Si n > entonces
My = n
Fin del si
Si mn < entonces
Mn = n
Fin del si
Fin del para
Fin

My = 0, mn = 999999999,
i=1

Ingrese 20numeros

Para i = 1
hasta 20

no
Ingrese numero + i

Si n<
entonces

Si n>
entonces

My =n

Mn = n

Fin

my=0
mn=9999999999
TextWindow.WriteLine("Ingrese 20 nmeros")
For i=1 to 20
TextWindow.WriteLine("Ingrese el numero "+i)
n=textwindow.Read()
If n>myr Then
my=n
EndIf
If n<mn then
mn=n
endif
EndFor
TextWindow.WriteLine("El nmero mayor es: "+my)
TextWindow.WriteLine("El nmero menor es: "+mn)

15) Pida al usuario un nmero indefinido de nmeros (mientras se tecleen nmeros que no sean
negativos). Despus de la introduccin de cada nmero aparecer en pantalla informacin sobre
el nmero de datos introducidos y la suma hasta el momento, as: "Has introducido 5 nmeros y
su suma es 38"
1. inicio
2. i=0, x=0,z=0
3. para i=0 hasta 20
4. Ingrese numero +i
5.x=x+z
6. visualizar "Has introducido i nmeros y su suma es + x
7. fin del para
8. fin
Inicio

I = 0, x = 0, z = 0

Para i = 1
hasta 20

no

Ingrese numero + i

X = x+z

Visualizar has
introducido + i numero
y su suma es +x

Fin

TextWindow.WriteLine("Ingrese 20 nmeros")
For i=1 To 20
TextWindow.WriteLine("Ingrese nmero "+i)
z=textwindow.Read()
x=x+z
TextWindow.WriteLine("Ha ingresado "+i+" y su suma es "+z)
Endfor

Si

16) Pida al usuario un nmero entero y muestre en pantalla sus divisores (exceptuando el 1 y el
propio nmero). Por ejemplo, si se introduce 20, debera aparecer
2 es divisor de 20
4 es divisor de 20
5 es divisor de 20
10 es divisor de 20

1.
2.
3.
4.
5.
6.
7.
8.
9.
10.

INICIO
I =2, N =0, R=0
INGRESE UN NUMERO
Para i = 2 hasta n
R al residuo n/i
Si r = 0 entonces
I es divisor de n
Fin del si
Fin del para
Fin
Inicio

I = 0, n = 0, r = 0

Ingrese un numero

Para i = 2
hasta n -1

no
R = al residuo n/i

Si r = 0
entonces

I es divisor de n

Fin

TextWindow.WriteLine("Ingrese un numero ")


n=textwindow.Read()
For i=2 To n-1
r=math.Remainder(n,i)
If r=0 Then
TextWindow.WriteLine(i+" Es divisor de "+n)
endif
EndFor

18) Mejora el ejercicio 16 para que avise si el nmero no tiene divisores, en vez de que la
pantalla quede en blanco.

1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.

INICIO
I =2, N =0, R=0
INGRESE UN NUMERO
Para i = 2 hasta n
R al residuo n/i
Si r = 0 entonces
I es divisor de n
De lo contrario
N no tiene divisor
Fin del si
Fin del para
Fin
Inicio

I = 0, n = 0, r = 0

Ingrese un numero

Para i = 2
hasta n -1

no
R = al residuo n/i

Si r = 0
entonces

si

I es divisor de n

N no tiene divisor

Fin

TextWindow.WriteLine("Ingrese un numero ")


n=textwindow.Read()
For i=2 To n-1
r=math.Remainder(n,i)
If r=0 Then
TextWindow.WriteLine(i+" Es divisor de "+n)
Else
Textwindow.writeline (n+ no tiene divisor)
endif
EndFor

18) Pida al usuario un nmero entero y una letra, y muestre en pantalla la letra repetida tantas
veces como indique el nmero. Por ejemplo, si el nmero es 10 y la letra es a, aparecera
Aaaaaaaaaa

1.
2.
3.
4.
5.
6.
7.

Inicio
I = 1 , N=0, L=0
Ingrese un numero
Ingrese una letra
Para i = 1 hasta n
Visualizar letra
Fin
Inicio

I= 1, N = 0, L = 0

Ingrese un numero

Ingrese una letra

Para i
=1
hasta n

no
Visualizar L

Fin

TextWindow.WriteLine("Ingrese un numero:" )
n=textwindow.Read()
TextWindow.WriteLine("Ingrese una letra: ")
l=textwindow.Read()
For i=1 To n
TextWindow.Write(l)
EndFor

si

19) Pida al usuario un nmero entero y muestre su tabla de multiplicar.


1. inicio
2. i=0, n=0, t=0
3. ingrese un numero
4. visualizar en pantalla "La tabla de multiplicar de n"
5. para i=1 hasta 10
6. t=n*i
7. visualizar en pantalla "i por n es igual t"
8. fin del para
9. fin

TextWindow.WriteLine("Ingres un numero: ")


n=textwindow.Read()
TextWindow.WriteLine("La tabla de multiplicar de "+n)
For i=1 To 10
t=n*i
TextWindow.Writeline(i+" por "+n+" es igual :"+t)
EndFor

20) Pida al usuario un nmero real y diga cuantas cifras enteras tiene (pista: habr que dividir
varias veces entre 10).

1.
2.
3.
4.
5.
6.

INICIO
Ingrese un numero
Para i= 1 hasta n
D =i / 10
C = math.floor
Fin del para

7.
8.
9.
10.
11.
12.
13.

Si c<2 entonces
(n+" Tiene "+c+" cifra entera")
De lo contrario
n+" Tiene "+c+" cifras enteras")
fin del si
fin

TextWindow.WriteLine("Ingrese un numero ")


n=textwindow.Read()
For i=1 To n
d=i/10
c=math.Floor(d)
EndFor
If c<2 Then
TextWindow.WriteLine(n+" Tiene "+c+" cifra entera")
Else
TextWindow.WriteLine(n+" Tiene "+c+" cifras enteras")
EndIf
inicio

Ingrese un numero

Para i = 1
hasta n

No
D = i/10

C = math.floor (d)

Si
Si c<2
entonces

no

si
N + tiene +c+
cifras enteras

N + tiene +c+
cifras enteras

Fin

You might also like