lunes, 26 de octubre de 2009

Practica 7.2 Visual

PSEUDOCODIGO
float n, I, x = 0.0;

PRINT("Introduzca un numero");
READ(n)

if (n < 2)
{
PRINT("Introduzca valores mayores que 2");
}

else if (n > 2)
{
for (I = 2; I <= n; I = I + 2)
{

PRINT(I)
x = x + I;
}

PRINT("La suma de los numeros pares es: {0}", x);
{

}
}
final









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 WindowsFormsApplication4
{
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<2)
{
textBox2.Text=("El valor es incorrecto");
}
for (i=2; i<=n; i=i+2)
{
suma=suma+i;
}
textBox2.Text = ("" + suma.ToString());
}

private void listBox1_SelectedIndexChanged(object sender, EventArgs e)
{

}
}
}

No hay comentarios:

Publicar un comentario