martes, 11 de septiembre de 2012

DESARROLLAR UN PROGRAMA QUE ME PERMITA LEER UN VALOR DESDE EL TECLADO Y DETERMINAR SI ES O NO UN NUMERO PRIMO


using System;

namespace verfdenumprimos
{
    class Program
    {
        public static void Main(string[] args)
        {
            char op;
            do{
            int num=0;
            num=IngresoDelNumero();
            int res=0,i=1,cont=0;
            do{
            if(num%i==0){  
                    res=1;
            cont=cont+res;
                }
                i++;
          }while(i<=num);
            if(cont==2){
                    Console.SetCursorPosition(15,6);
                    Console.Write("EL NUMERO INGRESADO SI ES PRIMO");
            }else{
                Console.SetCursorPosition(15,6);
                Console.Write("EL NUMERO INGRESADO NO ES PRIMO");
            }
            Console.SetCursorPosition(15,9);
            Console.Write("DESEA SEGUIR VERIFICANDO [S/N]:");
            op=char.Parse(Console.ReadLine());
            }while(op=='s');
            Console.ReadKey();
        }
      
      
      
        public static int IngresoDelNumero()
        {
            Console.Clear();
            int cant=0;
            Console.SetCursorPosition(15,4);
            Console.Write("INGRESE EL NUMERO A VERIFICAR: ");
          
            cant=int.Parse(Console.ReadLine());
            return cant;
          
          
          
        }
      
        }
    }


Fecha: 11 de Septiembre del 2012

IMPLEMENTAR UN PROGRAMA QUE ME PERMITA INGRESAR UN VALOR NUMERICO POSITIVO DE DOS DIGITOS. DETERMINAR SI EL PRIMER DIGITO ES MULTIPLO DEL SEGUNDO



using System;

namespace DosDigitos
{
    class Program
    {
        public static void Main(string[] args)
        {
            int num'='0;
            num'='IngresoPositivo();
            Multiplo(num);
            Console.ReadKey();
        }
        public static int IngresoPositivo()
        {
            int valor'='0;
             do{
                 Console.Clear();
                 Console.SetCursorPosition(10,4);
                 Console.Write("INGRESE EL VALOR NUMERICO: ");
                 valor'='int.Parse(Console.ReadLine());
             }while(valor'<'0);
            return valor;
        }
        public static int Multiplo(int cant)
        {
            int dig'='0;
            dig'='cant/10;
            cant'='cant%10;
            if(dig % cant' == '0){
                Console.SetCursorPosition(10,6);
                Console.Write("EL PRIMER DIGITO SI ES MULTIPLO DEL SEGUNDO");
            }
            else{
                Console.SetCursorPosition(10,6);
                Console.Write("EL PRIMER DIGITO NO ES MULTIPLO DEL SEGUNDO");
            }
            return cant;
        }
    }
}


Fecha:  11 de Septiembre del 2012


domingo, 12 de agosto de 2012

INGRESAR UN VALOR NUMÉRICO POR TECLADO Y OBTENER SU FACTORIAL


using System;

namespace Factorial
{
  class Program
  {
       public static void Main(string [] args)
       {
             int a'='0,f'='1;
             Console.Clear();
             Console.SetCursorPosition(10,2);
             Console.Write("INGRESE UN NUMERO: ");
             a'='Convert.ToInt16(Console.ReadLine());
             for(int i'='1;i'<='a;i++)
             {
                    f'='i*f;
             }
             Console.SetCursorPosition(14,4);
             Console.Write("EL FACTORIAL ES: {0}",f);
             Console.ReadKey();
       }
  }
}



Fecha: 12 de Agosto del 2012