Está en la página 1de 15

CODIGOS DE LOS

EJERCICIOS DEL GRUPO


1

Integrantes: Israel Alejandro Zambrana


Brittany Ibling Marino Quispe
Hugo brandon Quispe chambi
Rivaldo kari Laura
Gabriel Ticona
EJERCICIO 1 RAMDOM

namespace _4_operaciones
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}

private void Form1_Load(object sender, EventArgs e)


{
rdbsuma.Checked = true;
}

private void rdbresta_CheckedChanged(object sender, EventArgs e)


{

private void btncalcular_Click(object sender, EventArgs e)


{
double numero1, numero2, operacion;
numero1 = double.Parse(txtnumero1.Text);
numero2 = double.Parse(txtnumero2.Text);

if (rdbsuma.Checked == true)
{
operacion = numero1 + numero2;
}
else if (rdbresta.Checked == true)
{
operacion = numero1 - numero2;
}
else if (rdbmultiplicacion.Checked == true)
{
operacion = numero2 * numero2;
}
else
{
operacion = numero1 / numero2;
}

txtresultado.Text = operacion.ToString();

private void btnnuevo_Click(object sender, EventArgs e)


{
txtnumero1.Clear();
txtnumero2.Clear();
txtresultado.Clear();
txtnumero1.Focus();
}
}
}
EJERCICIO 2-Pedir un número y realizar su tabla de multiplicar.
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace EJERCICIO_2
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}

private void boton1_Click(object sender, EventArgs e)


{
listBox1.Items.Clear();
int TABLA = int.Parse(textBox1.Text);
int limite = int.Parse(textBox2.Text);
int resultado;
for(int i=1;i<=limite;i++)
{
resultado = TABLA * i;
listBox1.Items.Add(TABLA + "x" + i + "=" + resultado);
}
}
}
}

1.
EJERCICIO 3-Serie fibonaci

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace EJERCICIO3
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}

private void boton1_Click(object sender, EventArgs e)


{
int cant;
cant = Convert.ToInt32(textBox1.Text);
int i, f1 = 1, f2 = 1, f3 = 0;
listBox1.Items.Add(f1);
listBox1.Items.Add(f2);
for (i=3;i<=cant;i++)
{
f3 = f1 + f2;
listBox1.Items.Add(f3);
f1 = f2;
f2 = f3;
}
textBox2.Text = listBox1.Items.Count.ToString();
}
}
}
EJERCICIO 4-Realizar un programa que pida tres números y diga cuál es el mayor, cuál es el
segundo mayor, y cuál es el menor.
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace EJERCICIO4
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}

private void RESULTADO_Click(object sender, EventArgs e)


{
int a, b, c;
a = Convert.ToInt32(textBox1.Text);
b = Convert.ToInt32(textBox2.Text);
c = Convert.ToInt32(textBox3.Text);
{
if (a > b && a > c)

label5.Text = textBox1.Text;

else if (b > a && b > c)

label5.Text = textBox2.Text;

else if (c > a && c > b)

label5.Text = textBox3.Text;
}
{
if (a < b && a > c || a > b && a < c)

label7.Text = textBox1.Text;

else if (b < a && b > c|| b > a && b < c)

label7.Text = textBox2.Text;

else if (c < a && c > b|| c > a && c < b)

label7.Text = textBox3.Text;
}
{
if (a < b && a < c)

label9.Text = textBox1.Text;

else if (b < a && b < c)

label9.Text = textBox2.Text;
else if (c < a && c < b)

label9.Text = textBox3.Text;
}

}
}
}

EJERCICIO 5-Realizar un programa que pida al usuario dos números y presente los números
impares que hay desde el primer número al segundo que introdujo el usuario.
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace EJERCICIO5
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}

private void BOTON1_Click(object sender, EventArgs e)


{
impares.Items.Clear();
int INICIO = Convert.ToInt32(textBox1.Text);
int FINAL = Convert.ToInt32(textBox2.Text);
for (int i = INICIO; i <= FINAL; i++)
{
if (i % 2 == 1)
impares.Items.Add(i);

}
}

private void BOTON2_Click(object sender, EventArgs e)


{
textBox2.Clear();
textBox1.Clear();
textBox1.Focus();
impares.Items.Clear();
}
}
}
Ejercicio 6

using System;
using System.Collections.Generic;

using System.ComponentModel;

using System.Data;

using System.Drawing;

using System.Linq;

using System.Text;

using System.Threading.Tasks;

using System.Windows.Forms;

namespace Otra_ves

public partial class Form1 : Form

public Form1()

InitializeComponent();

private void Ordenador_Click(object sender, EventArgs e)

int i;

for (i = 1; i <= 100; i++)

if (i % 2 != 0)

listBox1.Items.Add(i);

private void button1_Click(object sender, EventArgs e)


{

int p;

for (p = 2; p <= 100; p=p+2)

listBox1.Items.Add(p);

private void button4_Click(object sender, EventArgs e)

listBox1.Items.Clear();

}
EJERCICIO 8

Un programa que pida al usuario dos valores y con esos valores se cree un
vector con sus elementos pares y el otro vector con elementos impares

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace WindowsFormsApp7
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}

private void button1_Click(object sender, EventArgs e)


{
int num,num1 = 0;
num = int.Parse(textBox1.Text);
num1 = int.Parse(textBox2.Text);
//num2 = int.Parse(textBox2.Text);

if (num % 2 == 0)
{
textBox3.Text= ("ES PAR");
}
else
{
textBox3.Text = ("ES IMPAR");
}
if (num1 % 2 == 0)
{
textBox4.Text = ("ES PAR");
}
else
{
textBox4.Text = ("ES IMPAR");
}

private void button2_Click(object sender, EventArgs e)


{
textBox1.Clear();
textBox2.Clear();
textBox3.Clear();
textBox4.Clear();
}

}
}
Ejercicio 9

using System;

using System.Collections.Generic;

using System.ComponentModel;

using System.Data;

using System.Drawing;

using System.Linq;

using System.Text;

using System.Threading.Tasks;

using System.Windows.Forms;

namespace divicion_y_su_resto_form

public partial class Form1 : Form

{
public Form1()

InitializeComponent();

private void Ordenador_Click(object sender, EventArgs e)

int res, num, fin, resid;

num = Convert.ToInt32(textBox1.Text);

fin = Convert.ToInt32(textBox2.Text);

res = num / fin;

resid = num % fin;

listBox1.Items.Add("La respuesta de la divicion es: " +res);

listBox1.Items.Add("El resto de la divicion es: " + resid);

private void button2_Click(object sender, EventArgs e)

listBox1.Items.Clear();

También podría gustarte