SlideShare a Scribd company logo
C# Inicialización
1. Bienvenido Nº1
using System;
class bienvenido
{
static void Main(string[] args)
{
Console.WriteLine("Bienbenido al programa de C# !");
Console.ReadLine();
}
}
2. Bienvenido Nº2
using System;
class bienvenido2
{
static void Main(string[] args)
{
Console.Write("Bienvenido al ");
Console.WriteLine("Programa C# !");
Console.ReadLine();
}
}
3. BienvenidoNº3
using System;
class Bienvenido3
{
static void Main(string[] args)
{
Console.WriteLine("BienvenidonalnProgramandeC#!");
Console.ReadLine();
}
}
4. Digitarun textode 4 cifras y que luegote muestre de formahorizontal lafrase.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
string cadena;
Console.Write("Texto de 4 cifras :");
cadena = Console.ReadLine();
Console.WriteLine(cadena[0]);
Console.WriteLine(cadena[1]);
Console.WriteLine(cadena[2]);
Console.WriteLine(cadena[3]);
Console.ReadLine();
}
}
}
5. Digite unacomunicacionescritaconcadenas
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
Console.Write("Hola ");
Console.WriteLine(" Erick");
Console.Write("¿Cómo andas,");
Console.WriteLine("tío?");
Console.ReadLine();
}
}
}
6. Creaciónde contraseñas
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
string clave = "erick";
string res = "";
while (res != clave)
{
Console.Write("Ingrese la clave:");
res = Console.ReadLine();
}
Console.WriteLine("La clave es correcta");
Console.ReadLine();
}
}
}
AAApppllliiicccaaaccciiióóónnn “““BBBAAASSSIIICCCAAA”””
1. Hallarla suma de 2 dígitos
using System;
class Addition
{
static void Main(string[] args)
{
int n1, n2, sum;
Console.Write("Primer Numero : ");
n1 = int.Parse (Console.ReadLine());
Console.Write("Segundo Numero: ");
n2 = int.Parse(Console.ReadLine());
sum = n1 + n2;
Console.WriteLine("la suma es : {0}", sum);
Console.ReadLine();
}
}
2. La compra de un producto halla el importe, IGV y sacar el total.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
string nombre;
double precio, cantidad, imp, igv, total;
Console.Write("nombre del producto :");
nombre = (Console.ReadLine());
Console.Write("precio :");
precio = double.Parse(Console.ReadLine());
Console.Write("cantidad :");
cantidad = double.Parse(Console.ReadLine());
imp = precio * cantidad;
igv = (19 / 100.0) * imp;
total = imp + igv;
Console.WriteLine("importe :{0}", imp);
Console.WriteLine("igv : {0}", igv);
Console.WriteLine("total : {0}", total);
Console.ReadLine();
}
}
}
3. Hallar el promedio final de un alumno sacando con tresnotas de sus estudios.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
string alumno;
double n1, n2, n3, p;
Console.Write("Alumno :");
alumno = (Console.ReadLine());
Console.Write("Nota 1 :");
n1 = double.Parse (Console.ReadLine());
Console.Write("Nota 2 :");
n2 = double.Parse (Console.ReadLine());
Console.Write("Nota 3 :");
n3 = double.Parse(Console.ReadLine());
p = (n1 + n2 + n3) / 3;
Console.WriteLine("promedio : {0}",p);
Console.ReadLine();
}
}
}
4. Hallar el pago de un cliente por la fecha de ingreso ante una empresa, hallando el total de
trabajo, IGV y el pago final.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[]
args)
{
string cliente;
string fdi;
double total, igv, pago;
Console.Write("Cliente :");
cliente = (Console.ReadLine());
Console.Write("Fecha de ingreso :");
fdi = (Console.ReadLine());
Console.Write("total :");
total = double.Parse(Console.ReadLine());
igv = total * (19 / 100.0);
pago = total + igv;
Console.WriteLine("igv :{0}", igv);
Console.WriteLine("pago :{0}", pago);
Console.ReadLine();
}
}
}
5. La venta de un producto “x” sacando la cantidad, IGV, pago final
using System;
using System.Collections.Generic;
using System.Text;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
string producto;
double cant, precio, total, igv, pagar;
Console.Write("Nombre del producto:");
producto = (Console.ReadLine());
Console.Write("cantidad : ");
cant = double.Parse(Console.ReadLine());
Console.Write("precio : ");
precio = double.Parse(Console.ReadLine());
total = cant * precio;
igv = (19 / 100.0) * total;
pagar = total + igv;
Console.WriteLine("total : {0}", total);
Console.WriteLine("igv : {0}", igv);
Console.WriteLine("pagar :{0}", pagar);
Console.ReadLine();
}
}
}
6. Ingrese un numero de 2 dígitos y mostrando en sentido al reverso.
using System;
using
System.Collections.Generic;
using System.Text;
namespace ConsoleApplication2
{
class Program
{
static void Main(string[] args)
{
int n, c, r, rpta;
Console.Write("Ingrese un numero de 2 digitos :");
n = int.Parse(Console.ReadLine());
c = n / 10;
r = n % 10;
rpta = r * 10 + c;
Console.WriteLine("Numero al reves : {0}", rpta);
Console.ReadLine();
}
}
}
7. Intercambia los primeros valores de dos numeros ejemplo
(a=12, b=34, a1=32, b1=14).
using System;
using System.Collections.Generic;
using System.Text;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
int n1, n2, rev1, rev2, res1, res2, can1, can2;
Console.ForegroundColor = ConsoleColor.Red;
Console.Write("Primer Número : ");
n1 = int.Parse(Console.ReadLine());
Console.Write("Segundo Número : ");
n2 = int.Parse(Console.ReadLine());
rev1 = n1 / 10;
res1 = n1 % 10;
rev2 = n2 / 10;
res2 = n2 % 10;
can1 = (rev2 * 10) + res1;
can2 = (rev1 * 10) + res2;
Console.ForegroundColor = ConsoleColor.Blue;
Console.WriteLine("Primer Número Invertido : {0}", can1);
Console.WriteLine("Segundo Número Invertido : {0}", can2);
Console.ReadLine();
}
}
}
AAApppllliiicccaaaccciiióóónnn cccooonnn “““MMMAAATTTHHH...”””
Ejercicio nº 1
Se ingresa el valor del lado de un cuadrado,¿calcularsu perímetro y su área?
 Perímetro=4 * lado
 Área = lado al cuadrado
using System;
using System.Collections.Generic;
using System.Text;
namespace ConsoleApplication2
{
class Program
{
static void Main(string[] args)
{
double r, diam, lc, area;
Console.Write("ingrese el valor de la radio :");
r = double.Parse(Console.ReadLine());
diam = 2 * r;
lc = 2 * Math.PI * r;
area = Math.PI * r * r;
Console.WriteLine("diametro : {0}", diam);
Console.WriteLine("longitud de la circunferencia :{0}", lc);
Console.WriteLine("area : {0}",area);
Console.ReadLine();
}
}
}
Ejercicio nº 2
 En un triángulo rectángulo,las proyecciones delos catetos sobre la hipotenusa miden 4 y 9
metros. ¿Calcular la altura relativa a la hipotenusa?.
using System;
using System.Collections.Generic;
using System.Text;
namespace ConsoleApplication2
{
class Program
{
static void Main(string[] args)
{
double c1, c2, h;
Console.Write("ingrese cateto 1:");
c1 = double.Parse(Console.ReadLine());
Console.Write("ingrese cateto 2:");
c2 = double.Parse(Console.ReadLine());
h = Math.Sqrt(c1 * c2);
Console.WriteLine("Hipotenusa : {0}", h);
Console.ReadLine();
}
}
PI
√ Raíz
}
Ejercicio nº 3
 Ingresar un número, elevarlo a la potencia determinada, ya sea al cuadrado, al
cubo, a la cuarta, etc.
using System;
using System.Collections.Generic;
using System.Text;
namespace ConsoleApplication2
{
class Program
{
static void Main(string[] args)
{
double n1, p, r;
Console.Write("ingrese un numero :");
n1 = double.Parse(Console.ReadLine());
Console.Write("elevalo a la potencia :");
p = double.Parse(Console.ReadLine());
r = Math.Pow(n1,p);
Console.WriteLine("resultado : {0}", r);
Console.ReadLine();
}
}
}
EJERCICIO Nº 4
Ingresar un valor de logaritmo, luego aplicándolo un número natural para sacar su
resultado final.
using System;
using System.Collections.Generic;
using System.Text;
namespace ConsoleApplication2
{
class Program
{
static void Main(string[] args)
{
double loga, n1, r;
Console.Write("ingrese logaritmo :");
loga = double.Parse(Console.ReadLine());
Console.Write("ingrese un numero :");
n1 = double.Parse(Console.ReadLine());
r = Math.Log (n1,loga);
Console.WriteLine("resultado : {0}", r);
Console.ReadLine();
}
}
}
Logaritmo
Potencia
EJERCICIO Nº 5
Hallar el coseno de un número ingresado en la aplicación de consola
using System;
using System.Collections.Generic;
using System.Text;
namespace ConsoleApplication2
{
class Program
{
static void Main(string[] args)
{
double n1, r;
Console.Write("ingrese un numero :");
n1 = double.Parse(Console.ReadLine());
r = Math.Cos (n1);
Console.WriteLine("El coseno del numero ingresado es : {0}", r);
Console.ReadLine();
}
}
}
EJERCICIO Nº 6
Aplicamos en una sola operación todo lo aprendido de “MATH.” EN C#.
using System;
using System.Collections.Generic;
using System.Text;
namespace ConsoleApplication2
{
class Program
{
static void Main(string[] args)
{
double z, x, a, p1, p2, p3;
a = 90;
x = Math.PI * a / 180;
p1 = Math.Pow(Math.Sin(x * x) + Math.Cos(x) * Math.Cos(x), 1 /
4.0);
p2=Math.Pow(Math.Log10(x)/(2*x),1/2.0);
p3 = Math.Log(Math.Pow(x, 4 / 3.0));
z = Math.Pow((p1 + p2) / p3, 1 / 9.0);
Console.WriteLine(" z = {0}",z);
Console.ReadLine();
}
}
}
Coseno
AAApppllliiicccaaaccciiióóónnn “““IIIFFF &&& EEELLLSSSEEE”””
EJERCICIO Nº 1
 Leer 2 notas de un alumno y mostrar el mensaje según su promedio, “APROBADO” O
“DESAPROBADO”
using System;
using System.Collections.Generic;
using System.Text;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
double n1, n2, prom;
Console.Write("ingrese 1º nota :");
n1 = double.Parse(Console.ReadLine());
Console.Write("ingrese 2º nota :");
n2 = double.Parse(Console.ReadLine());
prom = (n1 + n2) / 2;
Console.WriteLine("promedio : {0}", prom);
if (prom >= 10.5)
Console.WriteLine("APROBADO");
else
Console.WriteLine("DESAPROBADO");
Console.ReadLine();
}
}
}
OPERADORES LÓGICOS OPERADORES RELACIONADOS
PSEUDOCODIGO C# PSEUDOCODIGO C#
Y && > >
O || < <
NO ! >= >=
<= <=
= ==
<> !=
No tiene;porque enunc:
EJERCICIO Nº 2
 Leer 2 notas de un alumno y mostrar el mensaje según su promedio
PROMEDIO MENSAJE
0 - 10.49 DESAPROBADO
10.5 - 13.49 REGULAR
13.50 – 16.49 MUYBIEN
16.5 – 20.00 EXCELENTE
using System;
using System.Collections.Generic;
using System.Text;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
double n1, n2, prom;
Console.Write("ingrese 1º nota :");
n1 = double.Parse(Console.ReadLine());
Console.Write("ingrese 2º nota :");
n2 = double.Parse(Console.ReadLine());
prom = (n1 + n2) / 2;
Console.WriteLine("promedio : {0}", prom);
if (prom >= 0 && prom <= 10.49)
Console.WriteLine("DESAPROBADO");
else if (prom >= 10.50 && prom <= 13.49)
Console.WriteLine("REGULAR");
else if (prom >= 13.50 && prom <= 16.49)
Console.WriteLine("MUY BIEN");
else
Console.WriteLine("EXCELENTE");
Console.ReadLine();
}
}
}
EJERCICIO Nº 3
 Hacer un concurso de un participante en la cual debe de ingresar sus datos, y
sacar una de las 3 “llaves” para que gane un premio.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
string nombre;
string direccion;
int premio;
Console.WriteLine("Ingrese Numero de llave)");
Console.WriteLine("llave (1) llave(2) llave (3)");
Console.Write("Nombre :");
nombre = (Console.ReadLine());
Console.Write("Direccion :");
direccion = (Console.ReadLine());
Console.Write("Numero de llave :");
premio = int.Parse(Console.ReadLine());
if (premio == 1)
Console.WriteLine("GANO S/.10,000 NUEVOS SOLES");
else if (premio == 2)
Console.WriteLine("GANO UNA CASA");
else if (premio == 3)
Console.WriteLine("NO EXISTE PREMIO");
Console.ReadLine();
}
}
}
AAApppllliiicccaaaccciiióóónnn cccooonnn “““SSSwwwiiitttccchhh”””
EJERCICIO Nº 1
1. Leer un numero entre 1, 7 y mostrar el dia de la semana que representa.
using System;
using System.Collections.Generic;
using System.Text;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
int n;
string rpta;
rpta = "nro. No esta entre 1 y 7";
Console.Write("ingrese un nro. entre 1 y 7:");
n = int.Parse(Console.ReadLine());
switch (n)
{
case 1: rpta = "lunes"; break;
case 2: rpta = "martes"; break;
case 3: rpta = "miercoles"; break;
case 4: rpta = "jueves"; break;
case 5: rpta = "viernes"; break;
case 6: rpta = "sabado"; break;
case 7: rpta = "domingo"; break;
}
Console.WriteLine("{0}", rpta);
Console.ReadLine();
}
}
}
Ingrese unnúmeroentre 1 y 7: 2
Martes
Nº
2. Leer un numero entre 1, 12 y mostrar el mes de cada año que se representa.
using System;
using System.Collections.Generic;
using System.Text;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
int n;
string rpta = "No Es El Número Correcto";
Console.Write("Ingrese Un Numero Del 1 al 12 : ");
n = int.Parse(Console.ReadLine());
switch (n)
{
case 1: rpta = "Enero"; break;
case 2: rpta = "Febrero"; break;
case 3: rpta = "Marzo"; break;
case 4: rpta = "Abril"; break;
case 5: rpta = "Mayo"; break;
case 6: rpta = "Junio"; break;
case 7: rpta = "Julio"; break;
case 8: rpta = "Agosto"; break;
case 9: rpta = "Setiembre"; break;
case 10: rpta = "Octubre"; break;
case 11: rpta = "Noviembre"; break;
case 12: rpta = "Diciembre"; break;
}
Console.WriteLine("El Mes Es : {0}", rpta);
Console.ReadLine();
}
}
}
3. Leer un numero entero pisitivo entre 1 y 99 y muestre su
equivalencia en letras.
Ejemplo: 99 = Noventa y Nueve
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
int n, u, d;
string rpta = "";
Console.Write("Ingrese Un Número : ");
n = int.Parse(Console.ReadLine());
d = n / 10;
u = n % 10;
switch (u)
{
case 1: rpta = "Uno"; break;
case 2: rpta = "Dos"; break;
case 3: rpta = "Tres"; break;
case 4: rpta = "Cuatro"; break;
case 5: rpta = "Cinco"; break;
case 6: rpta = "Seis"; break;
case 7: rpta = "Siete"; break;
case 8: rpta = "Ocho"; break;
case 9: rpta = "Nueve"; break;
}
switch (d)
{
case 1: switch (u)
{
case 0: rpta = "Diez"; break;
case 1: rpta = "Once"; break;
case 2: rpta = "Doce"; break;
case 3: rpta = "Trece"; break;
case 4: rpta = "Catorce"; break;
case 5: rpta = "Quince"; break;
default: rpta = "Dieci" + rpta; break;
}
break;
case 2: if (u == 0) rpta = "Veinte"; else rpta = "Veinti" + rpta; break;
case 3: if (u == 0) rpta = "Treinta"; else rpta = "Treinta y " + rpta; break;
case 4: if (u == 0) rpta = "Curenta"; else rpta = "Cuarenta y " + rpta; break;
case 5: if (u == 0) rpta = "Cincuenta"; else rpta = "Cincuenta y" + rpta; break;
case 6: if (u == 0) rpta = "Sesenta"; else rpta = "Sesenta y " + rpta; break;
case 7: if (u == 0) rpta = "Setenta"; else rpta = "Setenta y" + rpta; break;
case 8: if (u == 0) rpta = "Ochenta"; else rpta = "Ochenta y " + rpta; break;
case 9: if (u == 0) rpta = "Noventa"; else rpta = "Noventa y " + rpta; break;
}
Console.WriteLine("Numero en Letras : {0}", rpta);
Console.ReadLine();
}
}
}
4. Leer un numero entero pisitivo entre 1 y 999 y muestre su
equivalencia en letras.
Ejemplo: 999 = Novecientos Noventa y Nueve
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
int num, cent, centres, dec, decres, uni;
string u = "", d = "", c = "";
Console.Write("Ingrese numero:");
num = int.Parse(Console.ReadLine());
cent = num / 100;
centres = num % 100;
dec = centres / 10;
decres = centres % 10;
uni = decres;
switch (uni)
{
case 1: u = "Uno "; break;
case 2: u = "Dos "; break;
case 3: u = "Tres "; break;
case 4: u = "Cuatro "; break;
case 5: u = "Cinco "; break;
case 6: u = "Seis "; break;
case 7: u = "Siete "; break;
case 8: u = "Ocho "; break;
case 9: u = "Nueve"; break;
}
switch (dec)
{
case 1: switch (uni)
{
case 0: u = "Diez"; break;
case 1: u = "Once"; break;
case 2: u = "Doce"; break;
case 3: u = "Trece"; break;
case 4: u = "Catorce"; break;
case 5: u = "Quince"; break;
default: u = "Dieci" + u; break;
}
break;
}
switch (dec)
{
case 2: if (uni == 0) d = "Veinte"; else d = "venti "; break;
case 3: if (uni == 0) d = "Treinta"; else d = "Treinta y "; break;
case 4: if (uni == 0) d = "Cuarenta "; else d = "Cuarenta y "; break;
case 5: if (uni == 0) d = "Cincuenta "; else d = "Cincuenta y "; break;
case 6: if (uni == 0) d = "Sesenta "; else d = "Sesenta y "; break;
case 7: if (uni == 0) d = "Setenta "; else d = "Setenta y "; break;
case 8: if (uni == 0) d = "Ocheta "; else d = "Ochenta y "; break;
case 9: if (uni == 0) d = "Noventa "; else d = "Noventa y "; break;
}
switch (cent)
{
case 1: if (uni == 0)
c = "Cien";
else
c = "ciento ";
break;
case 2: c = "Docientos "; break;
case 3: c = "Trecientos "; break;
case 4: c = "Cuatrocientos "; break;
case 5: c = "Quinientos "; break;
case 6: c = "Seiscientos "; break;
case 7: c = "Sietecientos "; break;
case 8: c = "Ochocientos "; break;
case 9: c = "Novecientos "; break;
}
Console.WriteLine("Numero En Letras : {0} ", c + d + u);
Console.ReadLine();
}
}
}
5. Leer un numero entero pisitivo entre 1 y 99 y muestre su
equivalencia en ingles.
Ejemplo: 99 = Ninety Nine
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
int n, u, d;
string rpta = "";
Console.Write("Ingrese Un Numero : ");
n = int.Parse(Console.ReadLine());
d = n / 10;
u = n % 10;
switch (u)
{
case 1: rpta = "One"; break;
case 2: rpta = "Two"; break;
case 3: rpta = "Three"; break;
case 4: rpta = "Four"; break;
case 5: rpta = "Five"; break;
case 6: rpta = "Six"; break;
case 7: rpta = "Seven"; break;
case 8: rpta = "Eigth"; break;
case 9: rpta = "Nine"; break;
}
switch (d)
{
case 1: switch (u)
{
case 0: rpta = "ten"; break;
case 1: rpta = "Eleven"; break;
case 2: rpta = "Twuelve"; break;
case 3: rpta = "Thirteen"; break;
case 4: rpta = "Forteen"; break;
case 5: rpta = "Fifteen"; break;
case 6: rpta = "Sixteen"; break;
case 7: rpta = "Seventeen"; break;
case 8: rpta = "Eighteen"; break;
case 9: rpta = "Nineteen"; break;
}
break;
case 2: if (u == 0) rpta = "Twenty"; else rpta = "Twenty " + rpta; break;
case 3: if (u == 0) rpta = "Thirty"; else rpta = "Thirty " + rpta; break;
case 4: if (u == 0) rpta = "Forty"; else rpta = "Forty " + rpta; break;
case 5: if (u == 0) rpta = "Fifty"; else rpta = "Fifty " + rpta; break;
case 6: if (u == 0) rpta = "Sixty"; else rpta = "Sixty " + rpta; break;
case 7: if (u == 0) rpta = "Seventy"; else rpta = "Seventy " + rpta; break;
case 8: if (u == 0) rpta = "Eigthy"; else rpta = "Eigthy " + rpta; break;
case 9: if (u == 0) rpta = "Ninety"; else rpta = "Ninety " + rpta; break;
}
Console.WriteLine("Numero En Ingles : {0}", rpta);
Console.ReadLine();
}
}
}
6. Leer un numero entero pisitivo entre 1 y 999 y muestre su
equivalencia en ingles.
Ejemplo: 999 = Nine Hundred Ninety Nine
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
int n, u, d, d1, c, c1;
string un = "", dec = "", cen = "";
Console.Write("Ingrese Un Numero : ");
n = int.Parse(Console.ReadLine());
c = n / 100;
c1 = n % 100;
d = c1/ 10;
d1 = c1 % 10;
u = d1;
switch (u)
{
case 1: un = "One"; break;
case 2: un = "Two"; break;
case 3: un = "Three"; break;
case 4: un = "Four"; break;
case 5: un = "Five"; break;
case 6: un = "Six"; break;
case 7: un = "Seven"; break;
case 8: un = "Eigth"; break;
case 9: un = "Nine"; break;
}
switch (d)
{
case 1: switch (u)
{
case 0: un = "ten"; break;
case 1: un = "Eleven"; break;
case 2: un = "Twuelve"; break;
case 3: un = "Thirteen"; break;
case 4: un = "Forteen"; break;
case 5: un = "Fifteen"; break;
case 6: un = "Sixteen"; break;
case 7: un = "Seventeen"; break;
case 8: un = "Eighteen"; break;
case 9: un = "Nineteen"; break;
}
break;
case 2: if (u == 0) dec = "Twenty"; else dec = "Twenty "; break;
case 3: if (u == 0) dec = "Thirty"; else dec = "Thirty "; break;
case 4: if (u == 0) dec = "Forty"; else dec = "Forty "; break;
case 5: if (u == 0) dec = "Fifty"; else dec = "Fifty "; break;
case 6: if (u == 0) dec = "Sixty"; else dec = "Sixty "; break;
case 7: if (u == 0) dec = "Seventy"; else dec = "Seventy "; break;
case 8: if (u == 0) dec = "Eigthy"; else dec = "Eigthy "; break;
case 9: if (u == 0) dec = "Ninety "; else dec = "Ninety "; break;
}
switch (c)
{
case 1: cen = "Hundred "; break;
case 2: cen = "Two Hundred "; break;
case 3: cen = "THree Hundred "; break;
case 4: cen = "Four Hundred "; break;
case 5: cen = "Five Hundred "; break;
case 6: cen = "Six Hundred "; break;
case 7: cen = "Seven Hundred "; break;
case 8: cen = "Eigth Hundred "; break;
case 9: cen = "Nine Hundred "; break;
}
Console.WriteLine("Numero En Ingles : {0}", cen + dec + un);
Console.ReadLine();
}
}
}
7. Leer un numero entero pisitivo entre 1 y 9999 y muestre su equivalencia en ingles.
Ejemplo: 999 = Nine Thousand Nine Hundred Ninety Nine
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
int n, u, d, d1, c, c1, mi, mi1;
string un = "", dec = "", cen = "", mil = "";
Console.Write("Ingrese Un Numero : ");
n = int.Parse(Console.ReadLine());
mi = n / 1000;
mi1 = n % 1000;
c = mi1 / 100;
c1 = mi1 % 100;
d = c1 / 10;
d1 = c1 % 10;
u = d1;
switch (u)
{
case 1: un = "One"; break;
case 2: un = "Two"; break;
case 3: un = "Three"; break;
case 4: un = "Four"; break;
case 5: un = "Five"; break;
case 6: un = "Six"; break;
case 7: un = "Seven"; break;
case 8: un = "Eigth"; break;
case 9: un = "Nine"; break;
}
switch (d)
{
case 1: switch (u)
{
case 0: un = "Ten"; break;
case 1: un = "Eleven"; break;
case 2: un = "Twuelve"; break;
case 3: un = "Thirteen"; break;
case 4: un = "Forteen"; break;
case 5: un = "Fifteen"; break;
case 6: un = "Sixteen"; break;
case 7: un = "Seventeen"; break;
case 8: un = "Eighteen"; break;
case 9: un = "Nineteen"; break;
}
break;
case 2: if (u == 0) dec = "Twenty"; else dec = "Twenty "; break;
case 3: if (u == 0) dec = "Thirty"; else dec = "Thirty "; break;
case 4: if (u == 0) dec = "Forty"; else dec = "Forty "; break;
case 5: if (u == 0) dec = "Fifty"; else dec = "Fifty "; break;
case 6: if (u == 0) dec = "Sixty"; else dec = "Sixty "; break;
case 7: if (u == 0) dec = "Seventy"; else dec = "Seventy "; break;
case 8: if (u == 0) dec = "Eigthy"; else dec = "Eigthy "; break;
case 9: if (u == 0) dec = "Ninety "; else dec = "Ninety "; break;
}
switch (c)
{
case 1: cen = "Hundred "; break;
case 2: cen = "Two Hundred "; break;
case 3: cen = "THree Hundred "; break;
case 4: cen = "Four Hundred "; break;
case 5: cen = "Five Hundred "; break;
case 6: cen = "Six Hundred "; break;
case 7: cen = "Seven Hundred "; break;
case 8: cen = "Eigth Hundred "; break;
case 9: cen = "Nine Hundred "; break;
}
switch (mi)
{
case 1: mil = "Thousand "; break;
case 2: mil = "Two Thousand "; break;
case 3: mil = "Three Thousand "; break;
case 4: mil = "Four Thousand "; break;
case 5: mil = "Five Thousand "; break;
case 6: mil = "Six Thousand "; break;
case 7: mil = "Seven Thousand "; break;
case 8: mil = "Eight Thousand "; break;
case 9: mil = "Nine Thousand "; break;
}
Console.WriteLine("Numero En Ingles : {0}", mil + cen + dec + un);
Console.ReadLine();
}
}
}
8. convertir de un numero natural a un numero romano.
using System;
using System.Collections.Generic;
using System.Text;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
int num,cent,centres,dec,decres,uni;
string u = "",d="",c="";
Console.Write("Ingrese numero :");
num = int.Parse(Console.ReadLine());
cent = num / 100;
centres = num % 100;
dec = centres / 10;
decres=centres % 10;
uni = decres;
switch (uni) {
case 1: u = "I"; break;
case 2: u = "II"; break;
case 3: u = "III"; break;
case 4: u = "IV"; break;
case 5: u = "V"; break;
case 6: u = "VI"; break;
case 7: u = "VII"; break;
case 8: u = "VIII"; break;
case 9: u = "IX"; break;
}
switch (dec)
{
case 1: d = "X"; break;
case 2: d = "XX"; break;
case 3: d = "XXX"; break;
case 4: d = "XL"; break;
case 5: d = "L"; break;
case 6: d = "LX"; break;
case 7: d = "LXX"; break;
case 8: d = "LXXX"; break;
case 9: d = "XC"; break;
}
switch (cent) {
case 1: c = "C"; break;
case 2: c = "CC"; break;
case 3: c = "CCC"; break;
case 4: c = "CD"; break;
case 5: c = "D"; break;
case 6: c = "DC"; break;
case 7: c = "DCC"; break;
case 8: c = "DCCC"; break;
case 9: c = "CM"; break;
}
Console.WriteLine("Numero en romanos :{0}", c + d + u);
Console.ReadLine();
}
}
}
AAApppllliiicccaaaccciiióóónnn cccooonnn “““FFFOOORRR”””
1. Ingrese 5 numeros sucesivos, alicando for.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
int i;
for (i = 1; i <= 5; i++)
{
Console.WriteLine("Ingrese Numero: {0} ", i);
}
Console.ReadLine();
}
}
}
2. Ingrese 5 textos “Erick”.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
int i;
for (i = 1; i <= 5; i++)
{
Console.WriteLine("{0} Erick ", i);
}
Console.ReadLine();
}
}
}
3. Ingrese n numeros, de forma sucesiva.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
int i,n;
Console.Write("Ingese Valor :");
n = int.Parse(Console.ReadLine());
for (i = 1; i <= n; i++)
{
Console.WriteLine("Numero Ingresado : {0} ", i);
}
Console.ReadLine();
}
}
}
4. Ingrese n textos “Leon”, aplicando for.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
int i,n;
Console.Write("Ingese Valor :");
n = int.Parse(Console.ReadLine());
for (i = 1; i <= n; i++)
{
Console.WriteLine("{0} Leon ", i);
}
Console.ReadLine();
}
}
}
5. Aplicando for halla la suma de n numeros.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
int i, n, suma, suma1;
suma1 = 0;
Console.Write("ingrese valor:");
n = int.Parse(Console.ReadLine());
for (i = 1; i <= n; i++)
{
Console.Write("{0}º Numero :", i);
suma = int.Parse(Console.ReadLine());
suma1 = suma + suma1;
}
Console.WriteLine("Resultado de la Suma : {0}", suma1);
Console.ReadLine();
}
}
}
6. Hallar las 7 notasdeun alumno y sacar promedio
using System;
using System.Collections.Generic;
using System.Text;
namespace ConsoleApplication2
{
class Program
{
static void Main(string[] args)
{
int nota, suma, i;
double prom;
suma = 0;
for (i = 1; i <= 7; i++)
{
Console.Write("ingrese nota {0}:", i);
nota = int.Parse(Console.ReadLine());
suma = suma + nota;
}
prom = suma / 7.0; Console.WriteLine("el promedio es : {0}", prom);
Console.ReadLine();
}
}
}
7. Leer10 númerosy hallarel mayor
using System;
using System.Collections.Generic;
using System.Text;
namespace ConsoleApplication3
{
class Program
{
static void Main(string[] args)
{
int n, i, max;
max = 0;
for (i = 1; i <= 10; i++)
{
Console.Write("ingrese nro {0}:", i);
n = int.Parse(Console.ReadLine());
if (i == 1)
max = n;
if (n > max)
max = n;
}
Console.WriteLine("Numero mayor: {0}", max);
Console.ReadLine();
}
}
}
8. Leer10 númerosy hallarel menor
using System;
using System.Collections.Generic;
using System.Text;
namespace ConsoleApplication3
{
class Program
{
static void Main(string[] args)
{
int n, i, mim;
mim = 0;
for (i = 1; i <= 10; i++)
{
Console.Write("ingrese nro {0}:", i);
n = int.Parse(Console.ReadLine());
if (i == 1)
mim = n;
if (n < mim)
mim = n;
}
Console.WriteLine("Numero menor: {0}", mim);
Console.ReadLine();
}
}
}
9. Leer 10 números ymostrar cuantos sonpositivos ycuántos sonnegativos ymostrar cuantos ceros hay.
using System;
using System.Collections.Generic;
using System.Text;
namespace ConsoleApplication3
{
class Program
{
static void Main(string[] args)
{
int n,i,cp,cn,cc;
cp=0;
cn=0;
cc=0;
for (i = 1; i <= 10; i++)
{
Console.Write("ingrese nro {0}:", i);
n = int.Parse(Console.ReadLine());
if (n < 0)
cn = cn + 1;
else if (n > 0)
cp = cp + 1;
else
cc = cc + 1;
}
Console.WriteLine("Cantidad de positivo: {0}", cp);
Console.WriteLine("cantidad de negativo: {0}", cn);
Console.WriteLine("cantidad de ceros : {0}", cc);
Console.ReadLine();
}
}
}
10. Dado un rango numerico entero.inicial y numerico entero. Final,obtener la cantidad de
numeros positivos y negativos que existen en el rango.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
int ni, nf, i, cp = 0, cn = 0;
Console.Write("Numero Inicial : ");
ni = int.Parse(Console.ReadLine());
Console.Write("Numero Final : ");
nf = int.Parse(Console.ReadLine());
for (i = ni; i <= nf; i++)
{
Console.WriteLine("{0}", i);
if (i < 0)
cn = cn + 1;
else if (i > 0)
cp = cp + 1;
}
Console.WriteLine("Cantidad de Positivos : {0}", cp);
Console.WriteLine("Cantidad de negativos : {0}", cn);
Console.ReadLine();
}
}
}
11. Ingresar dos numeros “primer numero” y “segundo numero”, mostrando sucesivamentehasta
el “segundo numero”
using System;
using System.Collections.Generic;
using System.Text;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
int indice, indice2, a, b;
Console.Write("Ingrese el primer numero : ");
indice = int.Parse(Console.ReadLine());
Console.Write("Ingrese el segundo numero : ");
indice2 = int.Parse(Console.ReadLine());
for (int i = indice; i <= indice2; i++)
Console.WriteLine("{0}", i);
Console.ReadLine();
}
}
}
12. Ingresar un numero, automáticamente que muestre los siguientes numero sucesivos pares
using System;
using System.Collections.Generic;
using System.Text;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
int indice;
Console.Write("Ingrese cantidad :");
indice = int.Parse(Console.ReadLine());
for (int i = 1; i <= indice; i++)
if (i % 2 == 0)
Console.WriteLine(i);
Console.ReadLine();
}
}
}
13. Dado un rango de números enteros, obtener la cantidad de números enteros que contiene
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
int i, ni, nf, can;
Console.Write("numero Inicial : ");
ni = int.Parse(Console.ReadLine());
Console.Write("Numero Final : ");
nf = int.Parse(Console.ReadLine());
ni = ni + 1;
nf = nf - 1;
for (i = ni; i <= nf; i++)
Console.WriteLine("{0}", i);
can = nf - ni + 1;
Console.WriteLine("Cantidad : {0}", can);
Console.ReadLine();
}
}
}
14. Hallarla suma y el productode n numerosque sonpares
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
int n, i, s = 0, p = 1;
Console.Write("Ingrese Cantidad : ");
n = int.Parse(Console.ReadLine());
for (i = 1; i <= n; i++)
{
Console.WriteLine(i * 2);
s = s + i * 2;
p = p * i * 2;
}
Console.WriteLine("suma : {0}", s);
Console.WriteLine("Producto : {0}", p);
Console.ReadLine();
}
}
}
15. Ingresar un número y mostrar sucesivamente ordenado sucesivamentehasta llegar al número
indicado.
using System;
using System.Collections.Generic;
using System.Text;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
int indice,o=1;
Console.Write("Ingrese cantidad :");
indice = int.Parse(Console.ReadLine());
for (int i = 1; i <=indice ; i++)
Console.WriteLine(o+"/"+(i));
Console.ReadLine();
}
}
}
16. Ingresarun númeroymostrar losnúmerossucesivosindicadosal númeroingresado
using System;
using System.Collections.Generic;
using System.Text;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
int indice,o=1;
Console.Write("Ingrese cantidad :");
indice = int.Parse(Console.ReadLine());
for (int i = 1; i <=indice ; i++)
Console.WriteLine(i+ "+" + (i+1) +"/"+(i+2));
Console.ReadLine();
}
}
}
17. Hallarla tablade multiplicarhastael 12, ingresandounnumero“x”
using System;
using System.Collections.Generic;
using System.Text;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
int indice;
Console.Write("Ingrese un numero :");
indice = int.Parse(Console.ReadLine());
for (int i = 0; i <= 12; i++)
Console.WriteLine("{0}*{1}={2}",i,indice,i*indice);
Console.ReadLine();
}
}
}
18. Hallarla tablade multiplicardel 10 * 12, siendo sucesivamentedel 1hastael 10
using System;
using System.Collections.Generic;
using System.Text;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
//int indice;
//Console.Write("Ingrese cantidad :");
//indice = int.Parse(Console.ReadLine());
for (int i = 1; i <= 10; i++)
for (int j = 1; j <= 12;j++ )
Console.WriteLine("{0}*{1}={2}", i, j, i * j);
Console.ReadLine();
}
}
}
19. Mostrar losnúmerosdel 1al 20, enexcepciónde losmúltiplosde tres
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
for (int i = 1; i <= 20; i++)
{
if (i % 3 == 0) continue;
Console.WriteLine(i);
}
Console.ReadLine();
}
}
}
20. Una persona debe realizar unmuestreocon 50 personas para determinar el promediode pesode los
niños jóvenes adultos yviejos que existenensuzona habitacional. Se determinan las categorías conbase
en la siguiente tabla.
using System;
using System.Collections.Generic;
using System.Text;
namespace ConsoleApplication3
{
class Program
{
static void Main(string[] args)
{
int i, ni, jo, ad, vi, edad;
double peso, pn, pj, pa, pv, ppn, ppa,
ppj, ppv;
ni = 0;
jo = 0;
ad = 0;
vi = 0;
pn = 0;
pj = 0;
pa = 0;
pv = 0;
for (i = 1; i <= 5; i++)
{
Console.Write("ingrese edad:");
edad = int.Parse(Console.ReadLine());
Console.Write("ingrese peso:");
peso = double.Parse(Console.ReadLine());
if (edad >= 0 && edad <= 12)
{
pn = pn + peso;
ni = ni + 1;
}
else if (edad >= 13 && edad <= 29)
{
pj = pj + peso;
jo = jo + 1;
}
else if (edad >= 30 && edad <= 59)
{
pa = pa + peso;
ad = ad + 1;
}
else if (edad >= 60 && edad < 100)
{
pv = pv + peso;
vi = vi + 1;
}
}
if (ni > 0)
{
ppn = pn / ni;
Console.WriteLine("x peso niños:{0}", ppn);
}
if (jo > 0)
{
ppj = pj / jo;
Console.WriteLine("x peso jovenes: {0}", ppj);
}
if (ad > 0)
{
ppa = pa / ad;
Console.WriteLine("x peso adulto;{0}", ppa);
}
if (vi > 0)
{
ppv = pv / vi;
Console.WriteLine("x peso de viejo: {0}", ppv);
}
Console.ReadLine();
}
}
}
Cambiar Nº
21. AplicarunFOR dentrode otro FOR
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
int cf;
Console.Write("Cantidad de Facturas: ");
cf = int.Parse(Console.ReadLine());
for( int i=1;i<=cf;i++)
{
Console.WriteLine("");
Console.WriteLine("Factura Número{0}",i);
Console.WriteLine("Detalle de Facturas");
for (int j = 1; j <= 3; j++)
{
Console.WriteLine("Linea de detalle(0)", j);
}
}
Console.ReadLine();
}
}
}
AAApppllliiicccaaaccciiióóónnn cccooonnn “““AAARRRRRREEEGGGLLLOOOSSS”””
1. Ingresarn númerosenarreglos
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
int n, i;
int[] x = new int[20];
Console.Write("Ingrese cantidad : ");
n = int.Parse(Console.ReadLine());
for (i = 0; i < n; i++)
{
Console.Write("Ingrese numero :");
x[i] = int.Parse(Console.ReadLine());
}
for (i = 0; i < n; i++)
{
Console.WriteLine("Numero : x[" + i + "]:{0}", x[i]);
}
Console.ReadLine();
}
}
}
2. Hallarla suma de n númerosenarreglos
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
int n, i, sum=0;
int[] x = new int[20];
Console.Write("Ingrese Cantidad : ");
n = int.Parse(Console.ReadLine());
for (i = 0; i < n; i++)
{
Console.Write("Ingrese Numero : ");
x[i] = int.Parse(Console.ReadLine());
sum = sum + x[i];
}
for (i = 0; i < n; i++)
{
Console.WriteLine("Numero : x[" + i + "] : {0}", x[i]);
}
Console.WriteLine("Suma : {0}", sum);
Console.ReadLine();
}
}
}
3. Hallarel producto de n númerosenarreglos
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
int n, i, pro=1;
int[] x = new int[20];
Console.Write("Ingrese Cantidad : ");
n = int.Parse(Console.ReadLine());
for (i = 0; i < n; i++)
{
Console.Write("Ingrese Numero : ");
x[i] = int.Parse(Console.ReadLine());
pro = pro * x[i];
}
for (i = 0; i < n; i++)
{
Console.WriteLine("Numero : x[" + i + "] : {0}", x[i]);
}
Console.WriteLine("Producto : {0}", pro);
Console.ReadLine();
}
}
}
4. Ingresarn númerosenunarregloy encontrarel númeromenor.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
int n, i, min;
int[] x = new int[20];
Console.Write("Ingrese Cantidad : ");
n = int.Parse(Console.ReadLine());
for (i = 0; i < n; i++)
{
Console.Write("Ingrese Numero : ");
x[i] = int.Parse(Console.ReadLine());
}
min = x[0];
for (i = 1; i < n; i++)
{
if (x[i] < min)
min = x[i];
}
for (i = 0; i < n; i++)
{
Console.WriteLine("Numero : x[" + i + "] : {0}", x[i]);
}
Console.WriteLine("Minimo : {0}",min);
Console.ReadLine();
}
}
}
5. Ingresar n numeros y encontrar el numero mayor.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
int n, i, max;
int[] x = new int[20];
Console.Write("Ingrese Cantidad : ");
n = int.Parse(Console.ReadLine());
for (i = 0; i < n; i++)
{
Console.Write("Ingrese Numero : ");
x[i] = int.Parse(Console.ReadLine());
}
max = x[0];
for (i = 1; i < n; i++)
{
if (x[i] > max)
max = x[i];
}
for (i = 0; i < n; i++)
{
Console.WriteLine("Numero : x[" + i + "] : {0}", x[i]);
}
Console.WriteLine("Maximo : {0}", max);
Console.ReadLine();
}
}
}
6. Ingresar n numeros y buscar el numero deseado caso
contrario no encontrado.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
int n, i, sw, num;
int[] x = new int[20];
Console.Write("Ingrese Cantidad : ");
n = int.Parse(Console.ReadLine());
for (i = 0; i < n; i++)
{
Console.Write("Ingrese Numero : ");
x[i] = int.Parse(Console.ReadLine());
}
sw = 0;
Console.Write("Que Numero Desea Buscar : ");
num = int.Parse(Console.ReadLine());
for (i = 0; i < num; i++)
{
if (x[i] == num)
{
sw = 1;
Console.WriteLine("Numero Encontrado : {0}", num);
Console.WriteLine("Posicion : {0}", i);
}
}
if (sw == 0)
Console.WriteLine("Numero No Encontrado");
for (i = 0; i < n; i++)
{
Console.WriteLine("Numero : x[" + i + "] : {0}", x[i]);
}
Console.ReadLine();
}
}
}
7. Hallar un arrgelo con todo lo aprendido, suma,
producto,numero maximo, numero mino, y buscar el numero
deseado.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
int n, i, sum = 0, pro = 1, max, min, sw, num;
int[] x = new int[20];
Console.Write("Ingrese Cantidad : ");
n = int.Parse(Console.ReadLine());
for (i = 0; i < n; i++)
{
Console.Write("Ingrese Numero : ");
x[i] = int.Parse(Console.ReadLine());
sum = sum + x[i];
pro = pro * x[i];
}
max = x[0];
min = x[0];
for (i = 1; i < n; i++)
{
if (x[i] > max)
max = x[i];
if (x[i] < min)
min = x[i];
}
sw = 0;
Console.Write("Que numero desea buscar : ");
num = int.Parse(Console.ReadLine());
for (i = 0; i < num; i++)
{
if (x[i] == num)
{
sw = 1;
Console.WriteLine("Numero Encontrado : {0}", num);
Console.WriteLine("Posicion : {0}", i);
}
}
if (sw == 0)
Console.WriteLine("Numero No Encontrado");
for (i = 0; i < n; i++)
{
Console.WriteLine("Numero : x[" + i + "] : {0}", x[i]);
}
Console.WriteLine("Suma : {0}", sum);
Console.WriteLine("Producto : {0}", pro);
Console.WriteLine("Minimo : {0}", min);
Console.WriteLine("Maximo : {0}", max);
Console.ReadLine();
}
}
}
AAApppllliiicccaaaccciiióóónnn cccooonnn “““WWWHHHIIILLLEEE YYY DDDOOO”””
Ejercicio nº 1
1. Ingresardel Numero 1 al 10
using System;
using System.Collections.Generic;
using System.Text;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
int i;
i = 1;
while (i <= 10)
{
Console.WriteLine("{0}", i);
i = i + 1;
}
Console.ReadLine();
}
}
}
Ejercicio nº 2
2. Ingresardel 1 al 10
using System;
using System.Collections.Generic;
using System.Text;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
int i;
i = 1;
do
{
Console.WriteLine("{0}", i);
i = i + 1;
} while (i <= 10);
Console.ReadLine();
}
}
}
Ejercicio nº 3
3. Ingresar en numero del 1 al 999, aplicando el enter
using System;
using System.Collections.Generic;
using System.Text;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
int i;
i = 11;
while (i <= 999)
{
Console.WriteLine("{0}", i);
Console.ReadLine();
i = i + 1;
}
Console.ReadLine();
}
}
}
Ejercicio nº 4
4. Ingresarel númerodel 1 al 999 aplicandoel enter
using System;
using System.Collections.Generic;
using System.Text;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
int i;
i = 1;
do
{
Console.WriteLine("{0}", i);
i = i + 1;
Console.ReadLine();
} while (i <= 999);
Console.ReadLine();
}
}
}
Ejercicio nº 5
5. Leerun númeroy mostraren pantallasi esprimoo no mostrarcon una respuesta
using System;
using System.Collections.Generic;
using System.Text;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
int n, i; string rpta; char seguir;
do
{
Console.Write("ingrese un numero:");
n = int.Parse(Console.ReadLine());
rpta = " ES PRIMO";
for (i = 2; i <= n - 1; i++)
if (n % i == 0)
{
rpta = "NO ES PRIMO";
break;
}
Console.WriteLine("{0}", rpta);
Console.WriteLine("desea continuar (s/n):"); seguir =
char.Parse(Console.ReadLine());
} while (seguir == 's' || seguir == 's');
}
}
}
Ejercicio nº 6
Se presentar3 alumnospara hacer delegadosdelsalón:
6. HARRY, ATON Y MEDINA. Leer voto porvoto y mostrar el porcentaje que obtuvocada
unoconsiderandosololosvotosvalidos.Tambiénimprimirel nombre del ganador.No
se conoce de ante mano cuantaspersonasvan a votar.
using System;
using System.Collections.Generic;
using System.Text;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
int cv1, cv2, cv3, voto, max;
double total, pv1, pv2, pv3;
string ganador;
Console.WriteLine("(1) Harry (2) Anton");
Console.WriteLine("(3) Medina (4) fin");
cv1=0;cv2=0;cv3=0;
do
{
Console.Write("ingrese voto:");
voto = int.Parse(Console.ReadLine());
if (voto == 1)
cv1 = cv1 + 1;
else if (voto == 2)
cv2 = cv2 + 1;
else if (voto == 3)
cv3 = cv3 + 1;
} while (voto != 4);
total = cv1 + cv2 + cv3;
pv1=(cv1/total)*100;
pv2=(cv2/total)*100;
pv3=(cv3/total)*100;
Console.WriteLine("Harry:{0}",pv1);
Console.WriteLine("Anton:{0}",pv2);
Console.WriteLine("Medina:{0}",pv3);
max = cv1;
ganador ="Harry";
if (cv2>max)
{ max=cv2;
ganador="Anton";
}
if (cv3>max)
{
max =cv3;
ganador="Medina";
}
Console.WriteLine("Felicidades:{0}", ganador);
Console.ReadLine ();
}
}
Ejercicio nº 7
7. Leervariosnúmeros,hastaque el usuarioingrese CERO.Muestre Cuantosnúmeros
ingresóysu promedio.
using System;
using System.Collections.Generic;
using System.Text;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
int n, cont;
double suma, prom;
suma = 0; cont = 0;
do
{
Console.Write("ingrese un numero:");
n = int.Parse(Console.ReadLine());
cont = cont + 1;
suma = suma + 1;
} while (n != 0);
prom = suma / (cont - 1);
Console.WriteLine("cantidad de numeros: {0}", cont - 1);
Console.WriteLine("promedio: {0}", prom);
Console.ReadLine();
}
}
}
Ingrese número:7
Ingrese número:2
Ingrese número:6
Ingresé número:0
Cantidadde números:
3
Promedio:5
AAApppllliiicccaaaccciiióóónnn cccooonnn “““WWWHHHIIILLLEEE YYY DDDOOO”””
1. Creaciónde un semáforo
using System;
using System.Threading;
class Program
{
static void Main(string[] args)
{
Semaforo.Iniciar();
}
}
class Semaforo
{
public static void Iniciar()
{
new Thread(new Semaforo().Run).Start();
}
private void Run()
{
while (true)
{
Console.Title="Erick";
Console.Clear();
Console.ForegroundColor=ConsoleColor.Red;
Console.WriteLine("0");
Console.ForegroundColor=ConsoleColor.DarkGray;
Console.WriteLine("0n0");
Thread.Sleep(3000);
Console.Clear();
Console.WriteLine("0");
Console.ForegroundColor=ConsoleColor.Yellow;
Console.WriteLine("0");
Console.ForegroundColor=ConsoleColor.DarkGray;
Console.WriteLine("0");
Thread.Sleep(500);
Console.Clear();
Console.WriteLine("0n0");
Console.ForegroundColor=ConsoleColor.Green;
Console.WriteLine("0");
Thread.Sleep (3000);
}
}
}

More Related Content

What's hot

Formulario4
Formulario4Formulario4
Formulario4
implantarb101
 
Ejercicios De Algoritmos
Ejercicios De AlgoritmosEjercicios De Algoritmos
Ejercicios De Algoritmossemuvi
 
Nova microsoft word document
Nova microsoft word documentNova microsoft word document
Nova microsoft word document
Saša Ličina
 
exercise of basic computer programming.docx
exercise of basic computer programming.docxexercise of basic computer programming.docx
exercise of basic computer programming.docx
miftah88
 
Netb si and
Netb si andNetb si and
Netb si and
dagoberto sierra
 
Clang-tidy: путешествие внутрь AST C++
Clang-tidy: путешествие внутрь AST C++Clang-tidy: путешествие внутрь AST C++
Clang-tidy: путешествие внутрь AST C++
corehard_by
 
Bancocic
BancocicBancocic
Bancocic
edgarflores28
 
Comprendre la programmation fonctionnelle, Blend Web Mix le 02/11/2016
Comprendre la programmation fonctionnelle, Blend Web Mix le 02/11/2016Comprendre la programmation fonctionnelle, Blend Web Mix le 02/11/2016
Comprendre la programmation fonctionnelle, Blend Web Mix le 02/11/2016
Loïc Knuchel
 
Condicional
CondicionalCondicional
Condicional
Rodrigo Saavedra
 
algoritmos condicionales y simples.
algoritmos condicionales y simples.algoritmos condicionales y simples.
algoritmos condicionales y simples.
kathyziitajair
 
OpenResty/Lua 70+ Advanced Programming Skills and Optimization tips
OpenResty/Lua 70+ Advanced Programming Skills and Optimization tipsOpenResty/Lua 70+ Advanced Programming Skills and Optimization tips
OpenResty/Lua 70+ Advanced Programming Skills and Optimization tips
Ho Kim
 
Programming in C
Programming in CProgramming in C
Programming in C
Vineet Kumar Saini
 
Algoritmo secuencial
Algoritmo secuencialAlgoritmo secuencial
Algoritmo secuencial
Daneziita Laulate Flores
 
Tugas pemrograman jaringan
Tugas pemrograman jaringanTugas pemrograman jaringan
Tugas pemrograman jaringan
Banser Sahara
 
Sockets java
Sockets javaSockets java
Sockets java
Giovani Hernandez
 
[C++ Korea] Effective Modern C++ Study, Item 27, 29 - 30
[C++ Korea] Effective Modern C++ Study, Item 27, 29 - 30[C++ Korea] Effective Modern C++ Study, Item 27, 29 - 30
[C++ Korea] Effective Modern C++ Study, Item 27, 29 - 30
Chris Ohk
 

What's hot (16)

Formulario4
Formulario4Formulario4
Formulario4
 
Ejercicios De Algoritmos
Ejercicios De AlgoritmosEjercicios De Algoritmos
Ejercicios De Algoritmos
 
Nova microsoft word document
Nova microsoft word documentNova microsoft word document
Nova microsoft word document
 
exercise of basic computer programming.docx
exercise of basic computer programming.docxexercise of basic computer programming.docx
exercise of basic computer programming.docx
 
Netb si and
Netb si andNetb si and
Netb si and
 
Clang-tidy: путешествие внутрь AST C++
Clang-tidy: путешествие внутрь AST C++Clang-tidy: путешествие внутрь AST C++
Clang-tidy: путешествие внутрь AST C++
 
Bancocic
BancocicBancocic
Bancocic
 
Comprendre la programmation fonctionnelle, Blend Web Mix le 02/11/2016
Comprendre la programmation fonctionnelle, Blend Web Mix le 02/11/2016Comprendre la programmation fonctionnelle, Blend Web Mix le 02/11/2016
Comprendre la programmation fonctionnelle, Blend Web Mix le 02/11/2016
 
Condicional
CondicionalCondicional
Condicional
 
algoritmos condicionales y simples.
algoritmos condicionales y simples.algoritmos condicionales y simples.
algoritmos condicionales y simples.
 
OpenResty/Lua 70+ Advanced Programming Skills and Optimization tips
OpenResty/Lua 70+ Advanced Programming Skills and Optimization tipsOpenResty/Lua 70+ Advanced Programming Skills and Optimization tips
OpenResty/Lua 70+ Advanced Programming Skills and Optimization tips
 
Programming in C
Programming in CProgramming in C
Programming in C
 
Algoritmo secuencial
Algoritmo secuencialAlgoritmo secuencial
Algoritmo secuencial
 
Tugas pemrograman jaringan
Tugas pemrograman jaringanTugas pemrograman jaringan
Tugas pemrograman jaringan
 
Sockets java
Sockets javaSockets java
Sockets java
 
[C++ Korea] Effective Modern C++ Study, Item 27, 29 - 30
[C++ Korea] Effective Modern C++ Study, Item 27, 29 - 30[C++ Korea] Effective Modern C++ Study, Item 27, 29 - 30
[C++ Korea] Effective Modern C++ Study, Item 27, 29 - 30
 

Ejerc3 141204195452-conversion-gate01

  • 1. C# Inicialización 1. Bienvenido Nº1 using System; class bienvenido { static void Main(string[] args) { Console.WriteLine("Bienbenido al programa de C# !"); Console.ReadLine(); } } 2. Bienvenido Nº2 using System; class bienvenido2 { static void Main(string[] args) { Console.Write("Bienvenido al "); Console.WriteLine("Programa C# !"); Console.ReadLine(); } } 3. BienvenidoNº3 using System; class Bienvenido3 { static void Main(string[] args) { Console.WriteLine("BienvenidonalnProgramandeC#!"); Console.ReadLine(); } }
  • 2. 4. Digitarun textode 4 cifras y que luegote muestre de formahorizontal lafrase. using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace ConsoleApplication1 { class Program { static void Main(string[] args) { string cadena; Console.Write("Texto de 4 cifras :"); cadena = Console.ReadLine(); Console.WriteLine(cadena[0]); Console.WriteLine(cadena[1]); Console.WriteLine(cadena[2]); Console.WriteLine(cadena[3]); Console.ReadLine(); } } } 5. Digite unacomunicacionescritaconcadenas using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace ConsoleApplication1 { class Program { static void Main(string[] args) { Console.Write("Hola "); Console.WriteLine(" Erick"); Console.Write("¿Cómo andas,"); Console.WriteLine("tío?"); Console.ReadLine(); } } }
  • 3. 6. Creaciónde contraseñas using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace ConsoleApplication1 { class Program { static void Main(string[] args) { string clave = "erick"; string res = ""; while (res != clave) { Console.Write("Ingrese la clave:"); res = Console.ReadLine(); } Console.WriteLine("La clave es correcta"); Console.ReadLine(); } } }
  • 4. AAApppllliiicccaaaccciiióóónnn “““BBBAAASSSIIICCCAAA””” 1. Hallarla suma de 2 dígitos using System; class Addition { static void Main(string[] args) { int n1, n2, sum; Console.Write("Primer Numero : "); n1 = int.Parse (Console.ReadLine()); Console.Write("Segundo Numero: "); n2 = int.Parse(Console.ReadLine()); sum = n1 + n2; Console.WriteLine("la suma es : {0}", sum); Console.ReadLine(); } } 2. La compra de un producto halla el importe, IGV y sacar el total. using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace ConsoleApplication1 { class Program { static void Main(string[] args) { string nombre; double precio, cantidad, imp, igv, total; Console.Write("nombre del producto :"); nombre = (Console.ReadLine()); Console.Write("precio :"); precio = double.Parse(Console.ReadLine()); Console.Write("cantidad :"); cantidad = double.Parse(Console.ReadLine()); imp = precio * cantidad; igv = (19 / 100.0) * imp; total = imp + igv; Console.WriteLine("importe :{0}", imp); Console.WriteLine("igv : {0}", igv); Console.WriteLine("total : {0}", total); Console.ReadLine(); } } }
  • 5. 3. Hallar el promedio final de un alumno sacando con tresnotas de sus estudios. using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace ConsoleApplication1 { class Program { static void Main(string[] args) { string alumno; double n1, n2, n3, p; Console.Write("Alumno :"); alumno = (Console.ReadLine()); Console.Write("Nota 1 :"); n1 = double.Parse (Console.ReadLine()); Console.Write("Nota 2 :"); n2 = double.Parse (Console.ReadLine()); Console.Write("Nota 3 :"); n3 = double.Parse(Console.ReadLine()); p = (n1 + n2 + n3) / 3; Console.WriteLine("promedio : {0}",p); Console.ReadLine(); } } } 4. Hallar el pago de un cliente por la fecha de ingreso ante una empresa, hallando el total de trabajo, IGV y el pago final. using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace ConsoleApplication1 { class Program { static void Main(string[] args) { string cliente; string fdi; double total, igv, pago; Console.Write("Cliente :"); cliente = (Console.ReadLine()); Console.Write("Fecha de ingreso :"); fdi = (Console.ReadLine()); Console.Write("total :"); total = double.Parse(Console.ReadLine()); igv = total * (19 / 100.0); pago = total + igv; Console.WriteLine("igv :{0}", igv); Console.WriteLine("pago :{0}", pago); Console.ReadLine(); } } }
  • 6. 5. La venta de un producto “x” sacando la cantidad, IGV, pago final using System; using System.Collections.Generic; using System.Text; namespace ConsoleApplication1 { class Program { static void Main(string[] args) { string producto; double cant, precio, total, igv, pagar; Console.Write("Nombre del producto:"); producto = (Console.ReadLine()); Console.Write("cantidad : "); cant = double.Parse(Console.ReadLine()); Console.Write("precio : "); precio = double.Parse(Console.ReadLine()); total = cant * precio; igv = (19 / 100.0) * total; pagar = total + igv; Console.WriteLine("total : {0}", total); Console.WriteLine("igv : {0}", igv); Console.WriteLine("pagar :{0}", pagar); Console.ReadLine(); } } } 6. Ingrese un numero de 2 dígitos y mostrando en sentido al reverso. using System; using System.Collections.Generic; using System.Text; namespace ConsoleApplication2 { class Program { static void Main(string[] args) { int n, c, r, rpta; Console.Write("Ingrese un numero de 2 digitos :"); n = int.Parse(Console.ReadLine()); c = n / 10; r = n % 10; rpta = r * 10 + c; Console.WriteLine("Numero al reves : {0}", rpta); Console.ReadLine(); } } }
  • 7. 7. Intercambia los primeros valores de dos numeros ejemplo (a=12, b=34, a1=32, b1=14). using System; using System.Collections.Generic; using System.Text; namespace ConsoleApplication1 { class Program { static void Main(string[] args) { int n1, n2, rev1, rev2, res1, res2, can1, can2; Console.ForegroundColor = ConsoleColor.Red; Console.Write("Primer Número : "); n1 = int.Parse(Console.ReadLine()); Console.Write("Segundo Número : "); n2 = int.Parse(Console.ReadLine()); rev1 = n1 / 10; res1 = n1 % 10; rev2 = n2 / 10; res2 = n2 % 10; can1 = (rev2 * 10) + res1; can2 = (rev1 * 10) + res2; Console.ForegroundColor = ConsoleColor.Blue; Console.WriteLine("Primer Número Invertido : {0}", can1); Console.WriteLine("Segundo Número Invertido : {0}", can2); Console.ReadLine(); } } }
  • 8. AAApppllliiicccaaaccciiióóónnn cccooonnn “““MMMAAATTTHHH...””” Ejercicio nº 1 Se ingresa el valor del lado de un cuadrado,¿calcularsu perímetro y su área?  Perímetro=4 * lado  Área = lado al cuadrado using System; using System.Collections.Generic; using System.Text; namespace ConsoleApplication2 { class Program { static void Main(string[] args) { double r, diam, lc, area; Console.Write("ingrese el valor de la radio :"); r = double.Parse(Console.ReadLine()); diam = 2 * r; lc = 2 * Math.PI * r; area = Math.PI * r * r; Console.WriteLine("diametro : {0}", diam); Console.WriteLine("longitud de la circunferencia :{0}", lc); Console.WriteLine("area : {0}",area); Console.ReadLine(); } } } Ejercicio nº 2  En un triángulo rectángulo,las proyecciones delos catetos sobre la hipotenusa miden 4 y 9 metros. ¿Calcular la altura relativa a la hipotenusa?. using System; using System.Collections.Generic; using System.Text; namespace ConsoleApplication2 { class Program { static void Main(string[] args) { double c1, c2, h; Console.Write("ingrese cateto 1:"); c1 = double.Parse(Console.ReadLine()); Console.Write("ingrese cateto 2:"); c2 = double.Parse(Console.ReadLine()); h = Math.Sqrt(c1 * c2); Console.WriteLine("Hipotenusa : {0}", h); Console.ReadLine(); } } PI √ Raíz
  • 9. } Ejercicio nº 3  Ingresar un número, elevarlo a la potencia determinada, ya sea al cuadrado, al cubo, a la cuarta, etc. using System; using System.Collections.Generic; using System.Text; namespace ConsoleApplication2 { class Program { static void Main(string[] args) { double n1, p, r; Console.Write("ingrese un numero :"); n1 = double.Parse(Console.ReadLine()); Console.Write("elevalo a la potencia :"); p = double.Parse(Console.ReadLine()); r = Math.Pow(n1,p); Console.WriteLine("resultado : {0}", r); Console.ReadLine(); } } } EJERCICIO Nº 4 Ingresar un valor de logaritmo, luego aplicándolo un número natural para sacar su resultado final. using System; using System.Collections.Generic; using System.Text; namespace ConsoleApplication2 { class Program { static void Main(string[] args) { double loga, n1, r; Console.Write("ingrese logaritmo :"); loga = double.Parse(Console.ReadLine()); Console.Write("ingrese un numero :"); n1 = double.Parse(Console.ReadLine()); r = Math.Log (n1,loga); Console.WriteLine("resultado : {0}", r); Console.ReadLine(); } } } Logaritmo Potencia
  • 10. EJERCICIO Nº 5 Hallar el coseno de un número ingresado en la aplicación de consola using System; using System.Collections.Generic; using System.Text; namespace ConsoleApplication2 { class Program { static void Main(string[] args) { double n1, r; Console.Write("ingrese un numero :"); n1 = double.Parse(Console.ReadLine()); r = Math.Cos (n1); Console.WriteLine("El coseno del numero ingresado es : {0}", r); Console.ReadLine(); } } } EJERCICIO Nº 6 Aplicamos en una sola operación todo lo aprendido de “MATH.” EN C#. using System; using System.Collections.Generic; using System.Text; namespace ConsoleApplication2 { class Program { static void Main(string[] args) { double z, x, a, p1, p2, p3; a = 90; x = Math.PI * a / 180; p1 = Math.Pow(Math.Sin(x * x) + Math.Cos(x) * Math.Cos(x), 1 / 4.0); p2=Math.Pow(Math.Log10(x)/(2*x),1/2.0); p3 = Math.Log(Math.Pow(x, 4 / 3.0)); z = Math.Pow((p1 + p2) / p3, 1 / 9.0); Console.WriteLine(" z = {0}",z); Console.ReadLine(); } } } Coseno
  • 11. AAApppllliiicccaaaccciiióóónnn “““IIIFFF &&& EEELLLSSSEEE””” EJERCICIO Nº 1  Leer 2 notas de un alumno y mostrar el mensaje según su promedio, “APROBADO” O “DESAPROBADO” using System; using System.Collections.Generic; using System.Text; namespace ConsoleApplication1 { class Program { static void Main(string[] args) { double n1, n2, prom; Console.Write("ingrese 1º nota :"); n1 = double.Parse(Console.ReadLine()); Console.Write("ingrese 2º nota :"); n2 = double.Parse(Console.ReadLine()); prom = (n1 + n2) / 2; Console.WriteLine("promedio : {0}", prom); if (prom >= 10.5) Console.WriteLine("APROBADO"); else Console.WriteLine("DESAPROBADO"); Console.ReadLine(); } } } OPERADORES LÓGICOS OPERADORES RELACIONADOS PSEUDOCODIGO C# PSEUDOCODIGO C# Y && > > O || < < NO ! >= >= <= <= = == <> != No tiene;porque enunc:
  • 12. EJERCICIO Nº 2  Leer 2 notas de un alumno y mostrar el mensaje según su promedio PROMEDIO MENSAJE 0 - 10.49 DESAPROBADO 10.5 - 13.49 REGULAR 13.50 – 16.49 MUYBIEN 16.5 – 20.00 EXCELENTE using System; using System.Collections.Generic; using System.Text; namespace ConsoleApplication1 { class Program { static void Main(string[] args) { double n1, n2, prom; Console.Write("ingrese 1º nota :"); n1 = double.Parse(Console.ReadLine()); Console.Write("ingrese 2º nota :"); n2 = double.Parse(Console.ReadLine()); prom = (n1 + n2) / 2; Console.WriteLine("promedio : {0}", prom); if (prom >= 0 && prom <= 10.49) Console.WriteLine("DESAPROBADO"); else if (prom >= 10.50 && prom <= 13.49) Console.WriteLine("REGULAR"); else if (prom >= 13.50 && prom <= 16.49) Console.WriteLine("MUY BIEN"); else Console.WriteLine("EXCELENTE"); Console.ReadLine(); } } }
  • 13. EJERCICIO Nº 3  Hacer un concurso de un participante en la cual debe de ingresar sus datos, y sacar una de las 3 “llaves” para que gane un premio. using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace ConsoleApplication1 { class Program { static void Main(string[] args) { string nombre; string direccion; int premio; Console.WriteLine("Ingrese Numero de llave)"); Console.WriteLine("llave (1) llave(2) llave (3)"); Console.Write("Nombre :"); nombre = (Console.ReadLine()); Console.Write("Direccion :"); direccion = (Console.ReadLine()); Console.Write("Numero de llave :"); premio = int.Parse(Console.ReadLine()); if (premio == 1) Console.WriteLine("GANO S/.10,000 NUEVOS SOLES"); else if (premio == 2) Console.WriteLine("GANO UNA CASA"); else if (premio == 3) Console.WriteLine("NO EXISTE PREMIO"); Console.ReadLine(); } } }
  • 14. AAApppllliiicccaaaccciiióóónnn cccooonnn “““SSSwwwiiitttccchhh””” EJERCICIO Nº 1 1. Leer un numero entre 1, 7 y mostrar el dia de la semana que representa. using System; using System.Collections.Generic; using System.Text; namespace ConsoleApplication1 { class Program { static void Main(string[] args) { int n; string rpta; rpta = "nro. No esta entre 1 y 7"; Console.Write("ingrese un nro. entre 1 y 7:"); n = int.Parse(Console.ReadLine()); switch (n) { case 1: rpta = "lunes"; break; case 2: rpta = "martes"; break; case 3: rpta = "miercoles"; break; case 4: rpta = "jueves"; break; case 5: rpta = "viernes"; break; case 6: rpta = "sabado"; break; case 7: rpta = "domingo"; break; } Console.WriteLine("{0}", rpta); Console.ReadLine(); } } } Ingrese unnúmeroentre 1 y 7: 2 Martes Nº
  • 15. 2. Leer un numero entre 1, 12 y mostrar el mes de cada año que se representa. using System; using System.Collections.Generic; using System.Text; namespace ConsoleApplication1 { class Program { static void Main(string[] args) { int n; string rpta = "No Es El Número Correcto"; Console.Write("Ingrese Un Numero Del 1 al 12 : "); n = int.Parse(Console.ReadLine()); switch (n) { case 1: rpta = "Enero"; break; case 2: rpta = "Febrero"; break; case 3: rpta = "Marzo"; break; case 4: rpta = "Abril"; break; case 5: rpta = "Mayo"; break; case 6: rpta = "Junio"; break; case 7: rpta = "Julio"; break; case 8: rpta = "Agosto"; break; case 9: rpta = "Setiembre"; break; case 10: rpta = "Octubre"; break; case 11: rpta = "Noviembre"; break; case 12: rpta = "Diciembre"; break; } Console.WriteLine("El Mes Es : {0}", rpta); Console.ReadLine(); } } }
  • 16. 3. Leer un numero entero pisitivo entre 1 y 99 y muestre su equivalencia en letras. Ejemplo: 99 = Noventa y Nueve using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace ConsoleApplication1 { class Program { static void Main(string[] args) { int n, u, d; string rpta = ""; Console.Write("Ingrese Un Número : "); n = int.Parse(Console.ReadLine()); d = n / 10; u = n % 10; switch (u) { case 1: rpta = "Uno"; break; case 2: rpta = "Dos"; break; case 3: rpta = "Tres"; break; case 4: rpta = "Cuatro"; break; case 5: rpta = "Cinco"; break; case 6: rpta = "Seis"; break; case 7: rpta = "Siete"; break; case 8: rpta = "Ocho"; break; case 9: rpta = "Nueve"; break; } switch (d) { case 1: switch (u) { case 0: rpta = "Diez"; break; case 1: rpta = "Once"; break; case 2: rpta = "Doce"; break; case 3: rpta = "Trece"; break; case 4: rpta = "Catorce"; break; case 5: rpta = "Quince"; break; default: rpta = "Dieci" + rpta; break; } break; case 2: if (u == 0) rpta = "Veinte"; else rpta = "Veinti" + rpta; break; case 3: if (u == 0) rpta = "Treinta"; else rpta = "Treinta y " + rpta; break; case 4: if (u == 0) rpta = "Curenta"; else rpta = "Cuarenta y " + rpta; break; case 5: if (u == 0) rpta = "Cincuenta"; else rpta = "Cincuenta y" + rpta; break; case 6: if (u == 0) rpta = "Sesenta"; else rpta = "Sesenta y " + rpta; break; case 7: if (u == 0) rpta = "Setenta"; else rpta = "Setenta y" + rpta; break; case 8: if (u == 0) rpta = "Ochenta"; else rpta = "Ochenta y " + rpta; break; case 9: if (u == 0) rpta = "Noventa"; else rpta = "Noventa y " + rpta; break; } Console.WriteLine("Numero en Letras : {0}", rpta); Console.ReadLine(); } } }
  • 17. 4. Leer un numero entero pisitivo entre 1 y 999 y muestre su equivalencia en letras. Ejemplo: 999 = Novecientos Noventa y Nueve using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace ConsoleApplication1 { class Program { static void Main(string[] args) { int num, cent, centres, dec, decres, uni; string u = "", d = "", c = ""; Console.Write("Ingrese numero:"); num = int.Parse(Console.ReadLine()); cent = num / 100; centres = num % 100; dec = centres / 10; decres = centres % 10; uni = decres; switch (uni) { case 1: u = "Uno "; break; case 2: u = "Dos "; break; case 3: u = "Tres "; break; case 4: u = "Cuatro "; break; case 5: u = "Cinco "; break; case 6: u = "Seis "; break; case 7: u = "Siete "; break; case 8: u = "Ocho "; break; case 9: u = "Nueve"; break; } switch (dec) { case 1: switch (uni) { case 0: u = "Diez"; break; case 1: u = "Once"; break; case 2: u = "Doce"; break; case 3: u = "Trece"; break; case 4: u = "Catorce"; break; case 5: u = "Quince"; break; default: u = "Dieci" + u; break; } break; } switch (dec) { case 2: if (uni == 0) d = "Veinte"; else d = "venti "; break; case 3: if (uni == 0) d = "Treinta"; else d = "Treinta y "; break; case 4: if (uni == 0) d = "Cuarenta "; else d = "Cuarenta y "; break; case 5: if (uni == 0) d = "Cincuenta "; else d = "Cincuenta y "; break; case 6: if (uni == 0) d = "Sesenta "; else d = "Sesenta y "; break; case 7: if (uni == 0) d = "Setenta "; else d = "Setenta y "; break; case 8: if (uni == 0) d = "Ocheta "; else d = "Ochenta y "; break; case 9: if (uni == 0) d = "Noventa "; else d = "Noventa y "; break; } switch (cent) { case 1: if (uni == 0) c = "Cien"; else c = "ciento "; break; case 2: c = "Docientos "; break; case 3: c = "Trecientos "; break; case 4: c = "Cuatrocientos "; break; case 5: c = "Quinientos "; break; case 6: c = "Seiscientos "; break; case 7: c = "Sietecientos "; break; case 8: c = "Ochocientos "; break; case 9: c = "Novecientos "; break; } Console.WriteLine("Numero En Letras : {0} ", c + d + u); Console.ReadLine(); } } }
  • 18. 5. Leer un numero entero pisitivo entre 1 y 99 y muestre su equivalencia en ingles. Ejemplo: 99 = Ninety Nine using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace ConsoleApplication1 { class Program { static void Main(string[] args) { int n, u, d; string rpta = ""; Console.Write("Ingrese Un Numero : "); n = int.Parse(Console.ReadLine()); d = n / 10; u = n % 10; switch (u) { case 1: rpta = "One"; break; case 2: rpta = "Two"; break; case 3: rpta = "Three"; break; case 4: rpta = "Four"; break; case 5: rpta = "Five"; break; case 6: rpta = "Six"; break; case 7: rpta = "Seven"; break; case 8: rpta = "Eigth"; break; case 9: rpta = "Nine"; break; } switch (d) { case 1: switch (u) { case 0: rpta = "ten"; break; case 1: rpta = "Eleven"; break; case 2: rpta = "Twuelve"; break; case 3: rpta = "Thirteen"; break; case 4: rpta = "Forteen"; break; case 5: rpta = "Fifteen"; break; case 6: rpta = "Sixteen"; break; case 7: rpta = "Seventeen"; break; case 8: rpta = "Eighteen"; break; case 9: rpta = "Nineteen"; break; } break; case 2: if (u == 0) rpta = "Twenty"; else rpta = "Twenty " + rpta; break; case 3: if (u == 0) rpta = "Thirty"; else rpta = "Thirty " + rpta; break; case 4: if (u == 0) rpta = "Forty"; else rpta = "Forty " + rpta; break; case 5: if (u == 0) rpta = "Fifty"; else rpta = "Fifty " + rpta; break; case 6: if (u == 0) rpta = "Sixty"; else rpta = "Sixty " + rpta; break; case 7: if (u == 0) rpta = "Seventy"; else rpta = "Seventy " + rpta; break; case 8: if (u == 0) rpta = "Eigthy"; else rpta = "Eigthy " + rpta; break; case 9: if (u == 0) rpta = "Ninety"; else rpta = "Ninety " + rpta; break; } Console.WriteLine("Numero En Ingles : {0}", rpta); Console.ReadLine(); } } }
  • 19. 6. Leer un numero entero pisitivo entre 1 y 999 y muestre su equivalencia en ingles. Ejemplo: 999 = Nine Hundred Ninety Nine using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace ConsoleApplication1 { class Program { static void Main(string[] args) { int n, u, d, d1, c, c1; string un = "", dec = "", cen = ""; Console.Write("Ingrese Un Numero : "); n = int.Parse(Console.ReadLine()); c = n / 100; c1 = n % 100; d = c1/ 10; d1 = c1 % 10; u = d1; switch (u) { case 1: un = "One"; break; case 2: un = "Two"; break; case 3: un = "Three"; break; case 4: un = "Four"; break; case 5: un = "Five"; break; case 6: un = "Six"; break; case 7: un = "Seven"; break; case 8: un = "Eigth"; break; case 9: un = "Nine"; break; } switch (d) { case 1: switch (u) { case 0: un = "ten"; break; case 1: un = "Eleven"; break; case 2: un = "Twuelve"; break; case 3: un = "Thirteen"; break; case 4: un = "Forteen"; break; case 5: un = "Fifteen"; break; case 6: un = "Sixteen"; break; case 7: un = "Seventeen"; break; case 8: un = "Eighteen"; break; case 9: un = "Nineteen"; break; } break; case 2: if (u == 0) dec = "Twenty"; else dec = "Twenty "; break; case 3: if (u == 0) dec = "Thirty"; else dec = "Thirty "; break; case 4: if (u == 0) dec = "Forty"; else dec = "Forty "; break; case 5: if (u == 0) dec = "Fifty"; else dec = "Fifty "; break; case 6: if (u == 0) dec = "Sixty"; else dec = "Sixty "; break; case 7: if (u == 0) dec = "Seventy"; else dec = "Seventy "; break; case 8: if (u == 0) dec = "Eigthy"; else dec = "Eigthy "; break; case 9: if (u == 0) dec = "Ninety "; else dec = "Ninety "; break; } switch (c) { case 1: cen = "Hundred "; break; case 2: cen = "Two Hundred "; break; case 3: cen = "THree Hundred "; break; case 4: cen = "Four Hundred "; break; case 5: cen = "Five Hundred "; break; case 6: cen = "Six Hundred "; break; case 7: cen = "Seven Hundred "; break; case 8: cen = "Eigth Hundred "; break; case 9: cen = "Nine Hundred "; break; } Console.WriteLine("Numero En Ingles : {0}", cen + dec + un); Console.ReadLine(); } }
  • 20. } 7. Leer un numero entero pisitivo entre 1 y 9999 y muestre su equivalencia en ingles. Ejemplo: 999 = Nine Thousand Nine Hundred Ninety Nine using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace ConsoleApplication1 { class Program { static void Main(string[] args) { int n, u, d, d1, c, c1, mi, mi1; string un = "", dec = "", cen = "", mil = ""; Console.Write("Ingrese Un Numero : "); n = int.Parse(Console.ReadLine()); mi = n / 1000; mi1 = n % 1000; c = mi1 / 100; c1 = mi1 % 100; d = c1 / 10; d1 = c1 % 10; u = d1; switch (u) { case 1: un = "One"; break; case 2: un = "Two"; break; case 3: un = "Three"; break; case 4: un = "Four"; break; case 5: un = "Five"; break; case 6: un = "Six"; break; case 7: un = "Seven"; break; case 8: un = "Eigth"; break; case 9: un = "Nine"; break; } switch (d) { case 1: switch (u) { case 0: un = "Ten"; break; case 1: un = "Eleven"; break; case 2: un = "Twuelve"; break; case 3: un = "Thirteen"; break; case 4: un = "Forteen"; break; case 5: un = "Fifteen"; break; case 6: un = "Sixteen"; break; case 7: un = "Seventeen"; break; case 8: un = "Eighteen"; break; case 9: un = "Nineteen"; break; } break; case 2: if (u == 0) dec = "Twenty"; else dec = "Twenty "; break; case 3: if (u == 0) dec = "Thirty"; else dec = "Thirty "; break; case 4: if (u == 0) dec = "Forty"; else dec = "Forty "; break; case 5: if (u == 0) dec = "Fifty"; else dec = "Fifty "; break; case 6: if (u == 0) dec = "Sixty"; else dec = "Sixty "; break; case 7: if (u == 0) dec = "Seventy"; else dec = "Seventy "; break; case 8: if (u == 0) dec = "Eigthy"; else dec = "Eigthy "; break; case 9: if (u == 0) dec = "Ninety "; else dec = "Ninety "; break; } switch (c) { case 1: cen = "Hundred "; break; case 2: cen = "Two Hundred "; break; case 3: cen = "THree Hundred "; break; case 4: cen = "Four Hundred "; break; case 5: cen = "Five Hundred "; break; case 6: cen = "Six Hundred "; break; case 7: cen = "Seven Hundred "; break; case 8: cen = "Eigth Hundred "; break; case 9: cen = "Nine Hundred "; break; } switch (mi) { case 1: mil = "Thousand "; break; case 2: mil = "Two Thousand "; break; case 3: mil = "Three Thousand "; break; case 4: mil = "Four Thousand "; break; case 5: mil = "Five Thousand "; break; case 6: mil = "Six Thousand "; break; case 7: mil = "Seven Thousand "; break; case 8: mil = "Eight Thousand "; break; case 9: mil = "Nine Thousand "; break; }
  • 21. Console.WriteLine("Numero En Ingles : {0}", mil + cen + dec + un); Console.ReadLine(); } } } 8. convertir de un numero natural a un numero romano. using System; using System.Collections.Generic; using System.Text; namespace ConsoleApplication1 { class Program { static void Main(string[] args) { int num,cent,centres,dec,decres,uni; string u = "",d="",c=""; Console.Write("Ingrese numero :"); num = int.Parse(Console.ReadLine()); cent = num / 100; centres = num % 100; dec = centres / 10; decres=centres % 10; uni = decres; switch (uni) { case 1: u = "I"; break; case 2: u = "II"; break; case 3: u = "III"; break; case 4: u = "IV"; break; case 5: u = "V"; break; case 6: u = "VI"; break; case 7: u = "VII"; break; case 8: u = "VIII"; break; case 9: u = "IX"; break; } switch (dec) { case 1: d = "X"; break; case 2: d = "XX"; break; case 3: d = "XXX"; break; case 4: d = "XL"; break; case 5: d = "L"; break; case 6: d = "LX"; break; case 7: d = "LXX"; break; case 8: d = "LXXX"; break; case 9: d = "XC"; break; } switch (cent) { case 1: c = "C"; break; case 2: c = "CC"; break; case 3: c = "CCC"; break; case 4: c = "CD"; break; case 5: c = "D"; break; case 6: c = "DC"; break; case 7: c = "DCC"; break; case 8: c = "DCCC"; break; case 9: c = "CM"; break; } Console.WriteLine("Numero en romanos :{0}", c + d + u); Console.ReadLine(); } } }
  • 22. AAApppllliiicccaaaccciiióóónnn cccooonnn “““FFFOOORRR””” 1. Ingrese 5 numeros sucesivos, alicando for. using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace ConsoleApplication1 { class Program { static void Main(string[] args) { int i; for (i = 1; i <= 5; i++) { Console.WriteLine("Ingrese Numero: {0} ", i); } Console.ReadLine(); } } } 2. Ingrese 5 textos “Erick”. using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace ConsoleApplication1 { class Program { static void Main(string[] args) { int i; for (i = 1; i <= 5; i++) { Console.WriteLine("{0} Erick ", i); } Console.ReadLine(); } } }
  • 23. 3. Ingrese n numeros, de forma sucesiva. using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace ConsoleApplication1 { class Program { static void Main(string[] args) { int i,n; Console.Write("Ingese Valor :"); n = int.Parse(Console.ReadLine()); for (i = 1; i <= n; i++) { Console.WriteLine("Numero Ingresado : {0} ", i); } Console.ReadLine(); } } } 4. Ingrese n textos “Leon”, aplicando for. using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace ConsoleApplication1 { class Program { static void Main(string[] args) { int i,n; Console.Write("Ingese Valor :"); n = int.Parse(Console.ReadLine()); for (i = 1; i <= n; i++) { Console.WriteLine("{0} Leon ", i); } Console.ReadLine(); } } }
  • 24. 5. Aplicando for halla la suma de n numeros. using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace ConsoleApplication1 { class Program { static void Main(string[] args) { int i, n, suma, suma1; suma1 = 0; Console.Write("ingrese valor:"); n = int.Parse(Console.ReadLine()); for (i = 1; i <= n; i++) { Console.Write("{0}º Numero :", i); suma = int.Parse(Console.ReadLine()); suma1 = suma + suma1; } Console.WriteLine("Resultado de la Suma : {0}", suma1); Console.ReadLine(); } } } 6. Hallar las 7 notasdeun alumno y sacar promedio using System; using System.Collections.Generic; using System.Text; namespace ConsoleApplication2 { class Program { static void Main(string[] args) { int nota, suma, i; double prom; suma = 0; for (i = 1; i <= 7; i++) { Console.Write("ingrese nota {0}:", i); nota = int.Parse(Console.ReadLine()); suma = suma + nota; } prom = suma / 7.0; Console.WriteLine("el promedio es : {0}", prom); Console.ReadLine(); } } }
  • 25. 7. Leer10 númerosy hallarel mayor using System; using System.Collections.Generic; using System.Text; namespace ConsoleApplication3 { class Program { static void Main(string[] args) { int n, i, max; max = 0; for (i = 1; i <= 10; i++) { Console.Write("ingrese nro {0}:", i); n = int.Parse(Console.ReadLine()); if (i == 1) max = n; if (n > max) max = n; } Console.WriteLine("Numero mayor: {0}", max); Console.ReadLine(); } } } 8. Leer10 númerosy hallarel menor using System; using System.Collections.Generic; using System.Text; namespace ConsoleApplication3 { class Program { static void Main(string[] args) { int n, i, mim; mim = 0; for (i = 1; i <= 10; i++) { Console.Write("ingrese nro {0}:", i); n = int.Parse(Console.ReadLine()); if (i == 1) mim = n; if (n < mim) mim = n; } Console.WriteLine("Numero menor: {0}", mim); Console.ReadLine(); } } }
  • 26. 9. Leer 10 números ymostrar cuantos sonpositivos ycuántos sonnegativos ymostrar cuantos ceros hay. using System; using System.Collections.Generic; using System.Text; namespace ConsoleApplication3 { class Program { static void Main(string[] args) { int n,i,cp,cn,cc; cp=0; cn=0; cc=0; for (i = 1; i <= 10; i++) { Console.Write("ingrese nro {0}:", i); n = int.Parse(Console.ReadLine()); if (n < 0) cn = cn + 1; else if (n > 0) cp = cp + 1; else cc = cc + 1; } Console.WriteLine("Cantidad de positivo: {0}", cp); Console.WriteLine("cantidad de negativo: {0}", cn); Console.WriteLine("cantidad de ceros : {0}", cc); Console.ReadLine(); } } } 10. Dado un rango numerico entero.inicial y numerico entero. Final,obtener la cantidad de numeros positivos y negativos que existen en el rango. using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace ConsoleApplication1 { class Program { static void Main(string[] args) { int ni, nf, i, cp = 0, cn = 0; Console.Write("Numero Inicial : "); ni = int.Parse(Console.ReadLine()); Console.Write("Numero Final : "); nf = int.Parse(Console.ReadLine()); for (i = ni; i <= nf; i++) { Console.WriteLine("{0}", i); if (i < 0) cn = cn + 1; else if (i > 0) cp = cp + 1; } Console.WriteLine("Cantidad de Positivos : {0}", cp); Console.WriteLine("Cantidad de negativos : {0}", cn); Console.ReadLine(); } } }
  • 27. 11. Ingresar dos numeros “primer numero” y “segundo numero”, mostrando sucesivamentehasta el “segundo numero” using System; using System.Collections.Generic; using System.Text; namespace ConsoleApplication1 { class Program { static void Main(string[] args) { int indice, indice2, a, b; Console.Write("Ingrese el primer numero : "); indice = int.Parse(Console.ReadLine()); Console.Write("Ingrese el segundo numero : "); indice2 = int.Parse(Console.ReadLine()); for (int i = indice; i <= indice2; i++) Console.WriteLine("{0}", i); Console.ReadLine(); } } } 12. Ingresar un numero, automáticamente que muestre los siguientes numero sucesivos pares using System; using System.Collections.Generic; using System.Text; namespace ConsoleApplication1 { class Program { static void Main(string[] args) { int indice; Console.Write("Ingrese cantidad :"); indice = int.Parse(Console.ReadLine()); for (int i = 1; i <= indice; i++) if (i % 2 == 0) Console.WriteLine(i); Console.ReadLine(); } } }
  • 28. 13. Dado un rango de números enteros, obtener la cantidad de números enteros que contiene using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace ConsoleApplication1 { class Program { static void Main(string[] args) { int i, ni, nf, can; Console.Write("numero Inicial : "); ni = int.Parse(Console.ReadLine()); Console.Write("Numero Final : "); nf = int.Parse(Console.ReadLine()); ni = ni + 1; nf = nf - 1; for (i = ni; i <= nf; i++) Console.WriteLine("{0}", i); can = nf - ni + 1; Console.WriteLine("Cantidad : {0}", can); Console.ReadLine(); } } } 14. Hallarla suma y el productode n numerosque sonpares using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace ConsoleApplication1 { class Program { static void Main(string[] args) { int n, i, s = 0, p = 1; Console.Write("Ingrese Cantidad : "); n = int.Parse(Console.ReadLine()); for (i = 1; i <= n; i++) { Console.WriteLine(i * 2); s = s + i * 2; p = p * i * 2; } Console.WriteLine("suma : {0}", s); Console.WriteLine("Producto : {0}", p); Console.ReadLine(); } } }
  • 29. 15. Ingresar un número y mostrar sucesivamente ordenado sucesivamentehasta llegar al número indicado. using System; using System.Collections.Generic; using System.Text; namespace ConsoleApplication1 { class Program { static void Main(string[] args) { int indice,o=1; Console.Write("Ingrese cantidad :"); indice = int.Parse(Console.ReadLine()); for (int i = 1; i <=indice ; i++) Console.WriteLine(o+"/"+(i)); Console.ReadLine(); } } } 16. Ingresarun númeroymostrar losnúmerossucesivosindicadosal númeroingresado using System; using System.Collections.Generic; using System.Text; namespace ConsoleApplication1 { class Program { static void Main(string[] args) { int indice,o=1; Console.Write("Ingrese cantidad :"); indice = int.Parse(Console.ReadLine()); for (int i = 1; i <=indice ; i++) Console.WriteLine(i+ "+" + (i+1) +"/"+(i+2)); Console.ReadLine(); } } }
  • 30. 17. Hallarla tablade multiplicarhastael 12, ingresandounnumero“x” using System; using System.Collections.Generic; using System.Text; namespace ConsoleApplication1 { class Program { static void Main(string[] args) { int indice; Console.Write("Ingrese un numero :"); indice = int.Parse(Console.ReadLine()); for (int i = 0; i <= 12; i++) Console.WriteLine("{0}*{1}={2}",i,indice,i*indice); Console.ReadLine(); } } } 18. Hallarla tablade multiplicardel 10 * 12, siendo sucesivamentedel 1hastael 10 using System; using System.Collections.Generic; using System.Text; namespace ConsoleApplication1 { class Program { static void Main(string[] args) { //int indice; //Console.Write("Ingrese cantidad :"); //indice = int.Parse(Console.ReadLine()); for (int i = 1; i <= 10; i++) for (int j = 1; j <= 12;j++ ) Console.WriteLine("{0}*{1}={2}", i, j, i * j); Console.ReadLine(); } } }
  • 31. 19. Mostrar losnúmerosdel 1al 20, enexcepciónde losmúltiplosde tres using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace ConsoleApplication1 { class Program { static void Main(string[] args) { for (int i = 1; i <= 20; i++) { if (i % 3 == 0) continue; Console.WriteLine(i); } Console.ReadLine(); } } }
  • 32. 20. Una persona debe realizar unmuestreocon 50 personas para determinar el promediode pesode los niños jóvenes adultos yviejos que existenensuzona habitacional. Se determinan las categorías conbase en la siguiente tabla. using System; using System.Collections.Generic; using System.Text; namespace ConsoleApplication3 { class Program { static void Main(string[] args) { int i, ni, jo, ad, vi, edad; double peso, pn, pj, pa, pv, ppn, ppa, ppj, ppv; ni = 0; jo = 0; ad = 0; vi = 0; pn = 0; pj = 0; pa = 0; pv = 0; for (i = 1; i <= 5; i++) { Console.Write("ingrese edad:"); edad = int.Parse(Console.ReadLine()); Console.Write("ingrese peso:"); peso = double.Parse(Console.ReadLine()); if (edad >= 0 && edad <= 12) { pn = pn + peso; ni = ni + 1; } else if (edad >= 13 && edad <= 29) { pj = pj + peso; jo = jo + 1; } else if (edad >= 30 && edad <= 59) { pa = pa + peso; ad = ad + 1; } else if (edad >= 60 && edad < 100) { pv = pv + peso; vi = vi + 1; } } if (ni > 0) { ppn = pn / ni; Console.WriteLine("x peso niños:{0}", ppn); } if (jo > 0) { ppj = pj / jo; Console.WriteLine("x peso jovenes: {0}", ppj); } if (ad > 0) { ppa = pa / ad; Console.WriteLine("x peso adulto;{0}", ppa); } if (vi > 0) { ppv = pv / vi; Console.WriteLine("x peso de viejo: {0}", ppv); } Console.ReadLine(); } } } Cambiar Nº
  • 33. 21. AplicarunFOR dentrode otro FOR using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace ConsoleApplication1 { class Program { static void Main(string[] args) { int cf; Console.Write("Cantidad de Facturas: "); cf = int.Parse(Console.ReadLine()); for( int i=1;i<=cf;i++) { Console.WriteLine(""); Console.WriteLine("Factura Número{0}",i); Console.WriteLine("Detalle de Facturas"); for (int j = 1; j <= 3; j++) { Console.WriteLine("Linea de detalle(0)", j); } } Console.ReadLine(); } } }
  • 34. AAApppllliiicccaaaccciiióóónnn cccooonnn “““AAARRRRRREEEGGGLLLOOOSSS””” 1. Ingresarn númerosenarreglos using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace ConsoleApplication1 { class Program { static void Main(string[] args) { int n, i; int[] x = new int[20]; Console.Write("Ingrese cantidad : "); n = int.Parse(Console.ReadLine()); for (i = 0; i < n; i++) { Console.Write("Ingrese numero :"); x[i] = int.Parse(Console.ReadLine()); } for (i = 0; i < n; i++) { Console.WriteLine("Numero : x[" + i + "]:{0}", x[i]); } Console.ReadLine(); } } } 2. Hallarla suma de n númerosenarreglos using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace ConsoleApplication1 { class Program { static void Main(string[] args) { int n, i, sum=0; int[] x = new int[20]; Console.Write("Ingrese Cantidad : "); n = int.Parse(Console.ReadLine()); for (i = 0; i < n; i++) { Console.Write("Ingrese Numero : "); x[i] = int.Parse(Console.ReadLine()); sum = sum + x[i]; } for (i = 0; i < n; i++) { Console.WriteLine("Numero : x[" + i + "] : {0}", x[i]); } Console.WriteLine("Suma : {0}", sum); Console.ReadLine(); } }
  • 35. } 3. Hallarel producto de n númerosenarreglos using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace ConsoleApplication1 { class Program { static void Main(string[] args) { int n, i, pro=1; int[] x = new int[20]; Console.Write("Ingrese Cantidad : "); n = int.Parse(Console.ReadLine()); for (i = 0; i < n; i++) { Console.Write("Ingrese Numero : "); x[i] = int.Parse(Console.ReadLine()); pro = pro * x[i]; } for (i = 0; i < n; i++) { Console.WriteLine("Numero : x[" + i + "] : {0}", x[i]); } Console.WriteLine("Producto : {0}", pro); Console.ReadLine(); } } } 4. Ingresarn númerosenunarregloy encontrarel númeromenor. using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace ConsoleApplication1 { class Program { static void Main(string[] args) { int n, i, min; int[] x = new int[20]; Console.Write("Ingrese Cantidad : "); n = int.Parse(Console.ReadLine()); for (i = 0; i < n; i++) { Console.Write("Ingrese Numero : "); x[i] = int.Parse(Console.ReadLine()); } min = x[0]; for (i = 1; i < n; i++) { if (x[i] < min) min = x[i]; } for (i = 0; i < n; i++) { Console.WriteLine("Numero : x[" + i + "] : {0}", x[i]); } Console.WriteLine("Minimo : {0}",min); Console.ReadLine(); }
  • 36. } } 5. Ingresar n numeros y encontrar el numero mayor. using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace ConsoleApplication1 { class Program { static void Main(string[] args) { int n, i, max; int[] x = new int[20]; Console.Write("Ingrese Cantidad : "); n = int.Parse(Console.ReadLine()); for (i = 0; i < n; i++) { Console.Write("Ingrese Numero : "); x[i] = int.Parse(Console.ReadLine()); } max = x[0]; for (i = 1; i < n; i++) { if (x[i] > max) max = x[i]; } for (i = 0; i < n; i++) { Console.WriteLine("Numero : x[" + i + "] : {0}", x[i]); } Console.WriteLine("Maximo : {0}", max); Console.ReadLine(); } } }
  • 37. 6. Ingresar n numeros y buscar el numero deseado caso contrario no encontrado. using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace ConsoleApplication1 { class Program { static void Main(string[] args) { int n, i, sw, num; int[] x = new int[20]; Console.Write("Ingrese Cantidad : "); n = int.Parse(Console.ReadLine()); for (i = 0; i < n; i++) { Console.Write("Ingrese Numero : "); x[i] = int.Parse(Console.ReadLine()); } sw = 0; Console.Write("Que Numero Desea Buscar : "); num = int.Parse(Console.ReadLine()); for (i = 0; i < num; i++) { if (x[i] == num) { sw = 1; Console.WriteLine("Numero Encontrado : {0}", num); Console.WriteLine("Posicion : {0}", i); } } if (sw == 0) Console.WriteLine("Numero No Encontrado"); for (i = 0; i < n; i++) { Console.WriteLine("Numero : x[" + i + "] : {0}", x[i]); } Console.ReadLine(); } } }
  • 38. 7. Hallar un arrgelo con todo lo aprendido, suma, producto,numero maximo, numero mino, y buscar el numero deseado. using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace ConsoleApplication1 { class Program { static void Main(string[] args) { int n, i, sum = 0, pro = 1, max, min, sw, num; int[] x = new int[20]; Console.Write("Ingrese Cantidad : "); n = int.Parse(Console.ReadLine()); for (i = 0; i < n; i++) { Console.Write("Ingrese Numero : "); x[i] = int.Parse(Console.ReadLine()); sum = sum + x[i]; pro = pro * x[i]; } max = x[0]; min = x[0]; for (i = 1; i < n; i++) { if (x[i] > max) max = x[i]; if (x[i] < min) min = x[i]; } sw = 0; Console.Write("Que numero desea buscar : "); num = int.Parse(Console.ReadLine()); for (i = 0; i < num; i++) { if (x[i] == num) { sw = 1; Console.WriteLine("Numero Encontrado : {0}", num); Console.WriteLine("Posicion : {0}", i); } } if (sw == 0) Console.WriteLine("Numero No Encontrado"); for (i = 0; i < n; i++) { Console.WriteLine("Numero : x[" + i + "] : {0}", x[i]); } Console.WriteLine("Suma : {0}", sum); Console.WriteLine("Producto : {0}", pro); Console.WriteLine("Minimo : {0}", min); Console.WriteLine("Maximo : {0}", max); Console.ReadLine(); } } }
  • 39. AAApppllliiicccaaaccciiióóónnn cccooonnn “““WWWHHHIIILLLEEE YYY DDDOOO””” Ejercicio nº 1 1. Ingresardel Numero 1 al 10 using System; using System.Collections.Generic; using System.Text; namespace ConsoleApplication1 { class Program { static void Main(string[] args) { int i; i = 1; while (i <= 10) { Console.WriteLine("{0}", i); i = i + 1; } Console.ReadLine(); } } } Ejercicio nº 2 2. Ingresardel 1 al 10 using System; using System.Collections.Generic; using System.Text; namespace ConsoleApplication1 { class Program { static void Main(string[] args) { int i; i = 1; do { Console.WriteLine("{0}", i); i = i + 1; } while (i <= 10); Console.ReadLine(); } } }
  • 40. Ejercicio nº 3 3. Ingresar en numero del 1 al 999, aplicando el enter using System; using System.Collections.Generic; using System.Text; namespace ConsoleApplication1 { class Program { static void Main(string[] args) { int i; i = 11; while (i <= 999) { Console.WriteLine("{0}", i); Console.ReadLine(); i = i + 1; } Console.ReadLine(); } } } Ejercicio nº 4 4. Ingresarel númerodel 1 al 999 aplicandoel enter using System; using System.Collections.Generic; using System.Text; namespace ConsoleApplication1 { class Program { static void Main(string[] args) { int i; i = 1; do { Console.WriteLine("{0}", i); i = i + 1; Console.ReadLine(); } while (i <= 999); Console.ReadLine(); } } }
  • 41. Ejercicio nº 5 5. Leerun númeroy mostraren pantallasi esprimoo no mostrarcon una respuesta using System; using System.Collections.Generic; using System.Text; namespace ConsoleApplication1 { class Program { static void Main(string[] args) { int n, i; string rpta; char seguir; do { Console.Write("ingrese un numero:"); n = int.Parse(Console.ReadLine()); rpta = " ES PRIMO"; for (i = 2; i <= n - 1; i++) if (n % i == 0) { rpta = "NO ES PRIMO"; break; } Console.WriteLine("{0}", rpta); Console.WriteLine("desea continuar (s/n):"); seguir = char.Parse(Console.ReadLine()); } while (seguir == 's' || seguir == 's'); } } }
  • 42. Ejercicio nº 6 Se presentar3 alumnospara hacer delegadosdelsalón: 6. HARRY, ATON Y MEDINA. Leer voto porvoto y mostrar el porcentaje que obtuvocada unoconsiderandosololosvotosvalidos.Tambiénimprimirel nombre del ganador.No se conoce de ante mano cuantaspersonasvan a votar. using System; using System.Collections.Generic; using System.Text; namespace ConsoleApplication1 { class Program { static void Main(string[] args) { int cv1, cv2, cv3, voto, max; double total, pv1, pv2, pv3; string ganador; Console.WriteLine("(1) Harry (2) Anton"); Console.WriteLine("(3) Medina (4) fin"); cv1=0;cv2=0;cv3=0; do { Console.Write("ingrese voto:"); voto = int.Parse(Console.ReadLine()); if (voto == 1) cv1 = cv1 + 1; else if (voto == 2) cv2 = cv2 + 1; else if (voto == 3) cv3 = cv3 + 1; } while (voto != 4); total = cv1 + cv2 + cv3; pv1=(cv1/total)*100; pv2=(cv2/total)*100; pv3=(cv3/total)*100; Console.WriteLine("Harry:{0}",pv1); Console.WriteLine("Anton:{0}",pv2); Console.WriteLine("Medina:{0}",pv3); max = cv1; ganador ="Harry"; if (cv2>max) { max=cv2; ganador="Anton"; } if (cv3>max) { max =cv3; ganador="Medina"; } Console.WriteLine("Felicidades:{0}", ganador); Console.ReadLine (); } }
  • 43. Ejercicio nº 7 7. Leervariosnúmeros,hastaque el usuarioingrese CERO.Muestre Cuantosnúmeros ingresóysu promedio. using System; using System.Collections.Generic; using System.Text; namespace ConsoleApplication1 { class Program { static void Main(string[] args) { int n, cont; double suma, prom; suma = 0; cont = 0; do { Console.Write("ingrese un numero:"); n = int.Parse(Console.ReadLine()); cont = cont + 1; suma = suma + 1; } while (n != 0); prom = suma / (cont - 1); Console.WriteLine("cantidad de numeros: {0}", cont - 1); Console.WriteLine("promedio: {0}", prom); Console.ReadLine(); } } } Ingrese número:7 Ingrese número:2 Ingrese número:6 Ingresé número:0 Cantidadde números: 3 Promedio:5
  • 44. AAApppllliiicccaaaccciiióóónnn cccooonnn “““WWWHHHIIILLLEEE YYY DDDOOO””” 1. Creaciónde un semáforo using System; using System.Threading; class Program { static void Main(string[] args) { Semaforo.Iniciar(); } } class Semaforo { public static void Iniciar() { new Thread(new Semaforo().Run).Start(); } private void Run() { while (true) { Console.Title="Erick"; Console.Clear(); Console.ForegroundColor=ConsoleColor.Red; Console.WriteLine("0"); Console.ForegroundColor=ConsoleColor.DarkGray; Console.WriteLine("0n0"); Thread.Sleep(3000); Console.Clear(); Console.WriteLine("0"); Console.ForegroundColor=ConsoleColor.Yellow; Console.WriteLine("0"); Console.ForegroundColor=ConsoleColor.DarkGray; Console.WriteLine("0"); Thread.Sleep(500); Console.Clear(); Console.WriteLine("0n0"); Console.ForegroundColor=ConsoleColor.Green; Console.WriteLine("0"); Thread.Sleep (3000); } } }