• Jueves 28 de Marzo de 2024, 20:24

Autor Tema:  TIPOS DE FUNCIONES  (Leído 873 veces)

NICY

  • Miembro activo
  • **
  • Mensajes: 42
  • Nacionalidad: mx
    • Ver Perfil
TIPOS DE FUNCIONES
« en: Viernes 19 de Junio de 2009, 00:20 »
0
class Program
    {
        static void suma()
        {


            int a, b, s;
            Console.WriteLine("captures 2 numeros:");
            a = int.Parse(Console.ReadLine());
            b = int.Parse(Console.ReadLine());
            s = a + b;

            Console.WriteLine("suma:{0}",s);

        }
        static void Main(string[] args)
        {
            suma();
            Console.ReadKey();
       

        }
    }
}

*****************************************************************
  2   segundo ejercicio

F,QUE  CON PARAMETROS


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

namespace ConsoleApplication2
{
    class Program
    {
       
       
   
        static void suma(int a, int b)
        {
            int s;
            s=a+b;
            Console.WriteLine("suma:{0}",s);


           

        }
        static void Main(string[] args)
        {

              int c, d;
            Console.WriteLine("captures 2 numeros:");
            c = int.Parse(Console.ReadLine());
            d = int.Parse(Console.ReadLine());
            suma (c, d);

            suma(8, 10);
            suma(4, 10);
            suma(8, 1);
           

   
            Console.ReadKey();
       

        }
    }
}
***************************************************************************

3 ejercicio

F, QUE REGRESA VALOR




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

namespace ejercicio_2
{
    class Program
    {
        static int suma()
        {
            int a, b, s;
            Console.WriteLine("captures 2 numeros:");
            a = int.Parse(Console.ReadLine());
            b = int.Parse(Console.ReadLine());
            s = a + b;
            return s;

        }

        static void Main(string[] args)
        {
                   int res= suma();
                   Console.WriteLine("suma{0}",res);
                   Console.ReadKey();
 
       
        }
    }
}
***************************************************************************
 4 programa

F. CON PARAMETROS QUE REGRESA VALOR



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

namespace ejercicio_2
{
    class Program
    {
        static int suma(int a, int b)
        {
            int  s;
            s = a + b;
            return s;

           
        }

        static void Main(string[] args)
        {
            int c, d;

            Console.WriteLine("captures 2 numeros:");
            c = int.Parse(Console.ReadLine());
            d = int.Parse(Console.ReadLine());
            Console.WriteLine("suma{0}", suma(c,d));

               
                   Console.ReadKey();
 
       
        }
    }
}