private void btnCalculate_Click(object sender, EventArgs e)
{
//variable declarations
int num;
//clear the listbox
lstPwrs.Items.Clear();
//add header to listbox
lstPwrs.Items.Add("N\tN^2\tN^3");
//each subsequent line is displayed as N is incremented
//use a while loop to do this, as you must be able to create
//the proper output for any upper limit the user enters
//initialize loop variable, then loop
num = Convert.ToInt32( txtInput.Text );
while ( num <= 5 )
++num;
{
lstPwrs.Items.Add( Math.Pow( num, 1 ) + "\t" + Math.Pow( …
Run Code Online (Sandbox Code Playgroud)