You are on page 1of 4

Catalina sarmiento camacho

Ing sistemas
2 semestre 215-2bd

1. El ejercicio da el numero de digitos que tiene un entero

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace numero_de_digitos_que_tiene
{
class Program
{
static void Main(string[] args)
{
int entero = 0, cont = 0;
Console.WriteLine("digite el entero");
entero = Convert.ToInt32(Console.ReadLine());

if (entero == 0)
{
Console.Write (cont = cont + 1);

}
else
while (entero != 0)
{
entero = entero / 10;
Console.WriteLine(cont = cont + 1);

Console.WriteLine(" ");
Console.WriteLine("Presione enter para salir");
Console.ReadKey();
}
}
}

2. Dice si una palabra o frase es palíndromo o no

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace palindromo
{
class Program
{
static void Main(string[] args)
{
int x = 0, y = 0;
String palabra;
Console.WriteLine("digite la palabra o frase");
palabra =Console.ReadLine();
y = palabra.Length -1;
while ((x<=y) && (palabra [x]==palabra[y]))
{
x++;
y--;
}
if (y<=x)

Console.WriteLine("la palabra o frase si es palindromo");

else

Console.WriteLine("la palabra o frase no es palindromo");


Console.ReadKey();

}
}
}

3. Imprime un entero al reves

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace primo
{
class Program
{
static void Main(string[] args)
{
int x = 0; int y = 0;

Console.WriteLine("digite el entero");
x = Convert.ToInt32(Console.ReadLine());

do
{
y=((y*10)+(x % 10));
x=x/10;
}
while (x!=0);
Console.WriteLine(+y);
Console.ReadKey();
}
}
}

4. Da las tablas de multiplicar del 1 al 9

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace tablas_de_multiplicar
{
class Program
{
static void Main(string[] args)
{
int a = 0; int b = 0; int rta = a*b;

for (a=1; a<10; a++)


for (b = 1; b <= 10; b++)
{

rta = a * b;
Console.WriteLine(a + "*" + b + "=" + rta);
Console.ReadLine();
}

}
}
}

5. Dice cual es el digito de mayor valor en un entero

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace digito_mayor
{
class Program
{
static void Main(string[] args)
{
int entero = 0; int mayor = 0;

Console.WriteLine("digite el entero");
entero = Convert.ToInt32(Console.ReadLine());

if (entero == 0)
mayor = 0;
else
while (entero != 0)
{
if ((entero % 10) >= mayor)
{
mayor = entero % 10;
entero = entero / 10;
}
else
entero = entero / 10;
}
Console.WriteLine("el digito de mayor valor es"+mayor);
Console.ReadKey();

}
}

You might also like