int n, p = 1, c;
PRINT("Introduzca un numero entero");
READ n
for (c = 1; c <= n; c = c + 2)
{
p = p * c;
}
PRINT"El producto de los numeros impares al valor leido es: {0}", p);
FINAL
CODIGO EN CONSOLA:
int n, p = 1, c;
Console.WriteLine("Introduzca un numero entero");
n = int.Parse(Console.ReadLine());
for (c = 1; c <= n; c = c + 2)
{
p = p * c;
}
Console.WriteLine("\nEl producto de los numeros impares al valor leido es: {0}", p);
Console.ReadKey();
_consola(img).jpg)
CODIGO EN WINDOWS
private void button1_Click(object sender, EventArgs e)
{
double n, p = 1, c=0,x=0;
n = double.Parse(textBox1.Text);
for (c = 1.0; c <= n; c = c + 2.0)
{
listBox1.Items.Add(c.ToString());
p = p*c;
}
listBox1.Items.Add("producto de los impares " + p);
}
private void button2_Click(object sender, EventArgs e)
{
listBox1.Items.Clear();
textBox1.Text = "";
textBox1.Focus();
}
private void button3_Click(object sender, EventArgs e)
{
Application.Exit();
}

No hay comentarios:
Publicar un comentario