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();
}
}
}