Program that will ask the user to input a number, program will determine and display if the input is odd or even and it will also display all the sum of all even and numbers from the given input.
here's my code so far..
int sum = 0;
for (int i = 0; i <= input; i++)
{
if (i % 2 == 0)
{
sum += i;
lblAllEven.Text = sum.ToString();
lblOutput.Text = "EVEN";
}
else
{
lblAllOdd.Text = sum.ToString();
lblOutput.Text = "ODD";
}
}
please help me fix my code..
1
Expert's answer
2012-12-21T05:51:44-0500
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 { & private int Sum{get;set;} & private int Number{get;set;} & public Form1() & { InitializeComponent(); & }
Comments
Leave a comment