20091021

PRACTICA 7.8 PRODUCTO DE ENTEROS IMPARES

pseudocodigo.
inicio
int n, S = 1, c
print "INTRODUZCA UN NUMERO ENTERO"
Read n
for (c = 1 to c <= n step c = c + 2)
{
S= S* c
print "EL PRODUCTO DE LOS NUMEROS IMPARES ES: S
} fin









Escriba un programa que calcule e imprima el producto de los enteros impares del 1 al N. dar por el teclado el valor N.



using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
int n, S = 1, c;
Console.WriteLine("INTRODUZCA UN NUMERO ENTERO");
n = int.Parse(Console.ReadLine());
for (c = 1; c <= n; c = c + 2) { S= S* c; } Console.WriteLine("\nEL PRODUCTO DE LOS NUMEROS IMPARES ES: {0}", S); Console.ReadKey(); } } } PRODUCTO DE ENTEROS IMPARES (visual)








A continuacion el programa ejecutable , esperando y no sea erroneo,. se me precentaron algunos problemas ,. no es nada complejo ,.pero aqui esta..


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 WindowsFormsApplication1
{
public partial class Form1 : Form
{
int n, c,p=1;
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
Console.WriteLine("Introduzca un numero entero");
n = int.Parse(textBox1.Text);
for (c = 1; c <= n; c = c + 2)

{

p = p * c; } textBox2.Text = ("El producto de los numeros impares es=" + p.ToString());

} private void button2_Click(object sender, EventArgs e)

{ textBox1.Clear();

textBox2.Clear();

} private void button3_Click(object sender, EventArgs e)

{ Close(); } } }

No hay comentarios:

Publicar un comentario