PRACTICA 7.1 CONSOLA
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace PRACT7._1
{
class Program
{
static void Main(string[] args)
{
Double sumaserie = 1.0, termino;
int d;
Console.WriteLine("+{0}", 1);
for (d = 2; d <= 199; d = d + 2)
{
termino = 1.0 / d;
Console.WriteLine("+{0:f2}", termino);
sumaserie = sumaserie + termino;
}
Console.WriteLine("\n\nLA SUMA DE TODOS LOS NUMEROS ES={0:f2}", sumaserie);
Console.ReadLine();
}
}
}
PRACTICA7.1 WINDOWS
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace practica7._1windows
{
public partial class Form1 : Form
{
double SUMASERIE, TERMINO, VALOR;
int D;
public Form1()
{
TERMINO = D;
SUMASERIE = 1.0;
VALOR = 1;
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
}
private void button1_Click(object sender, EventArgs e)
{
listBox1.Items.Add("+" + VALOR.ToString());
for (D = 2; D <= 198; D = D + 2)
{
TERMINO = 1.0 / D;
listBox1.Items.Add("+" + TERMINO.ToString());
SUMASERIE = SUMASERIE + TERMINO;
}
listBox1.Items.Add("=" + SUMASERIE.ToString());
}
private void button2_Click(object sender, EventArgs e)
{
Close();
}
}
}
PRACTICA 7.2 CONSOLA
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace pract7._2
{
class Program
{
static void Main(string[] args)
{
Double n, i, suma = 0;
Console.WriteLine("\n\n\t\tINTRODUCE UN NUMERO PAR ENTERO ");
n = double.Parse(Console.ReadLine());
if (n <>
{
Console.WriteLine("\n\n\t\t EL VALOR ES INCORRECTO ");
}
for (i = 2; i <= n; i = i + 2)
{
suma = suma + i;
}
Console.WriteLine("\n\n\n\t\tLA SUMA DE LOS PARES ES: {0} ", suma);
Console.ReadLine();
}
}
}
PRACTICA7.2 WINDOWS
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace PRACT7._2_WIND
{
public partial class Form1 : Form
{
double n, i, suma;
public Form1()
{
n = i;
suma = 0;
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
n = double.Parse(textBox1.Text);
if (n <>
{
textBox2.Text = ("EL VALOR ES INCORRECTO");
}
for (i = 2; i < i =" i">
{
suma = suma + i;
}
textBox2.Text = ("LA SUMA DE LOS NUMAROS PARES A N ES:" + suma.ToString());
}
private void button2_Click(object sender, EventArgs e)
{
textBox1.Clear();
textBox2.Clear();
}
private void button3_Click(object sender, EventArgs e)
{
Close();
}
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace practica7._3consol
{
class Program
{
static void Main(string[] args)
{
double num, x, exponen;
x= 1;
Console.WriteLine("\n\t\tINTRODUCE UN NUMREO ENTERO");
num = double.Parse(Console.ReadLine());
Console.WriteLine("\n\nPOTENCIA \t NUMERO ELEVADO A LA POTENCIA \t\tRESULTADO");
while (x <= num)
{
exponen = Math.Pow(x, x);
Console.Write("\n{0} \t\t\t{1} \t\t\t\t{2}", x, x, exponen);
x = x + 1;
}
Console.ReadLine();
}
}
}
PRACTICA7.3 WINDOWS
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace pract7._3_wind
{
public partial class Form1 : Form
{
double n, x, y;
public Form1()
{
x = 1;
n = y;
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
n = double.Parse(textBox1.Text);
listBox1.Items.Add(" NUMERO POTENCIA RESULTADO");
for (x = 0; x <= n; x = x + 0)
{
y = 1 * Math.Pow(x, 1) + 1 * Math.Pow(x, 2) + 1 + x++;
listBox1.Items.Add(" " + x.ToString() + " " + x.ToString() + " " + y.ToString());
}
}
private void button2_Click(object sender, EventArgs e)
{
textBox1.Clear();
listBox1.Items.Clear();
}
private void button3_Click(object sender, EventArgs e)
{
Close();
}
private void Form1_Load(object sender, EventArgs e)
{
}
}
}
PRACTICA 7.4 CONSOLA
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
{
class Program
{
static void Main(string[] args)
{
double n;
int x;
double sumaimpar = 0.0;
double sumapar = 0.0;
Console.WriteLine("\n\n\tINTRODUCE EL NUMERO MAXIMO");
n = double.Parse(Console.ReadLine());
for (x = 1; x <= n; x = x + 1)
if (x % 2 == 1)
{
sumaimpar = sumaimpar + x;
}
else
{
sumapar = sumapar + x;
}
Console.WriteLine("\n\n\tLA SUMA DE LOS PRODUCTOS IMPARES ES: {0}", sumaimpar);
Console.WriteLine("\n\n\tLA SUMA DE LOS PRODUCTOS PARES ES {0}", sumapar);
if (sumapar <>
{
Console.WriteLine("\n\tLA SUMA DE IMPARES ES MAYOR");
}
else
{
Console.WriteLine("\n\tLA SUMA DE LOS PARES ES MAYOR");
}
Console.ReadKey();
}
}
}
PRACTICA7.4 WINDOWS
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace pract7._4wind
{
public partial class Form1 : Form
{
int n, suma, numero, suma1, numero1, mayor, menor,c;
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
n = int.Parse(textBox1.Text);
mayor = suma;
menor = suma1;
for (numero = 1; numero <= n; numero = numero + 2)
{
suma = suma + numero;
}
for (numero1 = 2; numero1 <= n; numero1 = numero1 + 2)
{
suma1 = suma1 + numero1;
if (suma > mayor)
{
mayor = suma;
}
c = c + 1;
}
textBox2.Text = ("LA SUMA DE LOS NUMEROS IMPARES ES:" + suma.ToString());
textBox3.Text = ("LA SUMA DE LOS NUMEROS IMPARES ES:" + suma1.ToString());
textBox4.Text = ("EL DATO MAYOR ES:" + mayor.ToString());
}
private void button2_Click(object sender, EventArgs e)
{
textBox1.Clear();
textBox2.Clear();
textBox3.Clear();
textBox4.Clear();
}
private void button3_Click(object sender, EventArgs e)
{
Close();
}
}
}
7.5 CONSOLA
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace pract7._5consol
{
class Program
{
static void Main(string[] args)
{
double n;
int x;
double sumaimpar = 0.0;
double sumapar = 0.0;
Console.WriteLine("\n\n\tINTRODUCE EL NUMERO MAXIMO");
n = double.Parse(Console.ReadLine());
for (x = 1; x <= n; x = x + 1)
{
if (x % 2 == 1)
{
sumaimpar = sumaimpar + x;
}
else
{
sumapar = sumapar + x;
}
}
Console.WriteLine("\n\n\tLA SUMA DE LOS NUMEROS IMPARES ES: {0}", sumaimpar);
Console.WriteLine("\n\n\tLA SUMA DE LOS NUMEROS PARES ES {0}", sumapar);
while(sumapar <>
{
Console.WriteLine("\n\tLA SUMA DE IMPARES ES MAYOR");
Console.ReadKey();
}
while(sumapar >sumaimpar)
{
Console.WriteLine("\n\tLA SUMA DE LOS PARES ES MAYOR");
Console.ReadKey();
}
}
}
}
PRACTICA 7.6 CONSOLA
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
int n, valor, mayor, menor, c = 1;
Console.WriteLine("INTRODUCE LA CANTIDAD DE NUMEROS");
n = int.Parse(Console.ReadLine());
Console.WriteLine("\n\t INTRODUCE UN VALOR ENTERO");
valor = int.Parse(Console.ReadLine());
mayor=valor;
menor=valor;
c=1;
while(c
{
Console.WriteLine("\n\tINTRODUCE UN VALOR ENTERO");
valor = int.Parse(Console.ReadLine());
if(valor>mayor)
{
mayor=valor;
}
if(valor
{
menor=valor;
}
c = c + 1;
}
Console.WriteLine("\n\tEL DATO MAYOR ES:{0}",mayor);
Console.WriteLine("\n\tEL DATO MENOR ES:{0}",menor);
Console.ReadKey();
}
}
}
PRACTICA 7.7 CONSOLA
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace pract7._7
{
class Program
{
static void Main(string[] args)
{
int i, n, dato;
Double p=0.0,promedio;
Console.WriteLine("INTRODUCE UN NUMERO N");
n = int.Parse(Console.ReadLine());
for (i = 1; i <= n; i++)
{
Console.WriteLine(" DATO {0}", i);
dato = int.Parse(Console.ReadLine());
p = p + dato;
}
promedio = p / n;
Console.WriteLine("promedio={0}", promedio);
Console.ReadKey();
}
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace EXAMEN_UNIDAD2_CONSOLA
{
class Program
{
static void Main(string[] args)
{
int C,N,P=1;
Console.WriteLine("\n\nINTRODUCE EL VALOR DE N");
N = int.Parse(Console.ReadLine());
Console.WriteLine("\n\tEL PRODUCTO DE LOS NUMEROS IMPARES A N ES.");
for (C = 1; C<=N; C = C + 2)
{
P=P*C;
}
Console.WriteLine("\n\tEL PRODUCTO ES:{0} ",P );
Console.ReadKey();
}
}
}
PRACT 7.8 WINDOWS
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text ;
using System.Windows.Forms;
namespace pract_7._7_windows
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
int N, P = 1, C;
N = int.Parse(textBox1.Text);
for (C = 1; C <= N; C = C + 2)
{
P = P * C ;
}
label2.Text = "El producto de los numeros es:";
textBox2.Text = label2.Text + P.ToString();
}
private void button2_Click(object sender, EventArgs e)
{
textBox1.Clear();
label2.Text = ("");
}
private void button3_Click(object sender, EventArgs e)
{
Close();
}
}
}
No hay comentarios:
Publicar un comentario