0% found this document useful (0 votes)
22 views2 pages

EDP Exercise 1

The document discusses event-driven programming and provides an example code snippet of an exercise that asks the user for a start and end number, compares them, and outputs the current index in a loop using increment or decrement based on whether start is greater than or less than end.

Uploaded by

Avegael Espina
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
22 views2 pages

EDP Exercise 1

The document discusses event-driven programming and provides an example code snippet of an exercise that asks the user for a start and end number, compares them, and outputs the current index in a loop using increment or decrement based on whether start is greater than or less than end.

Uploaded by

Avegael Espina
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

Event-Driven Programming

Name: Espina, Avegael H.


Section: BSIT 2F

Exercise 1
//Exercise 1.
//Ask user for start and end.
// Determine whether starts is greater than or less than the end
// IF the start and end is equal, provide output that they can't be equal
// Use decrement and increment accordingly
// Output the Current Index of the for loop
// Can be done in either Windows Forms or Console Program (+5 point if you can do)

{
int start = Convert.ToInt32(txtStart.Text);
int end = Convert.ToInt32(txtEnd.Text);
int index = 0;
bool error = false;
string message = "";

if (start < end)


{
for (index = start; index < end; index++)
{
message += "Current index: " + index + "\n";
}
}
else if (start > end)
{
for (index = start; index > end; index--)
{
message += "Current index: " + index + "\n";
}
}
else
{
error = true;
MessageBox.Show("Start and End can't be equals!",
"Error",
MessageBoxButtons.OK,
MessageBoxIcon.Error);
}
if (error)
{
MessageBox.Show(message,
"Sucess",
MessageBoxButtons.OK,
MessageBoxIcon.Information);
}

You might also like