Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Answer the following questions: Differentiate between a confirm message and an a

ID: 3913331 • Letter: A

Question

Answer the following questions:

Differentiate between a confirm message and an alert message, by explaining exactly what is displayed in each.

Give an example of where a break statement might be used. Be specific.

Explain how you can loop through an array, if you don’t know the number of elements in the array. Be specific.

Give a general description of when a for loop should be used, as opposed to a while loop.

Differentiate between a pretest loop and a posttest loop by defining each.  Also, give an example of each.

Explanation / Answer

1)

As the name simply implies in English:

Alert: Alerts you by giving some information. It can be informative, warning, error message or anything else but just an information. Alert usually have only one button OK or it can be a self closing flash message/popup as well.

Confirm: Confirms you by giving some information or question. You will require to take some decision (E.g. for confirmation like “Are you sure you want to delete this employee record?”; you will require to take decision on whether you want to submit deletion of an employee record. Confirm usually have buttons like OK-Cancel, Yes-No, Abort-Cancel-Retry types. You read the confirmation being asked and then provide your suggestion to system by clicking appropriate button available in confirmation box.

Both Alert and Confirm usually be browser based (buttons and style be default to browser) but you can implement your own logic and coding to have customized message style and alerting.

2)

Suppose you are working with loops. It is sometimes desirable to skip some statements inside the loop or terminate the loop immediately without checking the test expression.

In such cases, break and continue statements are used.

3 )

For Loops allow you to run through the loop when you know how many times you'd like it to run through the problem such as for (var i; i < 10; i++); this will continually increase i untill that condition returns false, any number can replace the 10 even a variable. but it will quit once the condition is no longer being met. This is best used again for loops that you know how when they should stop.

While Loops allow you a little more flexability in what you put in it, and when it will stop such as while ( i < 10) you can also substitue in a boolean(true/false) for 10 as well as many other types of varibles.

The key difference between the two is organization between them, if you were going to increase to 10 it'd be a lot cleaner and more readable to use a for statement, but on the other hand if you were to use an existing variable in your program in your loop parameters it'd be cleaner to just wright a while loop. In the For loop you MUST create a new variable, thats not true for the While loop.

4)

is executed at least once, since the condition is at the bottom of the loop.

3. General Syntax is :

Do while <condition>

<statements>

Loop General Syntax is

General Syntax is :

Do

<statements>

Loop while<condition>

4. Ex.

Do While intNumber < 100

lblNumber.Caption=intNumber

intNumber = intNumber + 1

Loop

Ex. Dim intNum as integer

Do

Form1.print intNum

intNum = intNum +1

Loop while(intnum <= 10)

PreTest Do/Loop PostTest Do/Loop 1. Do-while tests the loop condition each time through the loop & it keeps executing while the test expression is a true value. Loop while we check the condition at the bottom. 2.When the conditional expression is false then the statements in Do/Loop are skipped. When the loop while is used ,the body of loop

is executed at least once, since the condition is at the bottom of the loop.

3. General Syntax is :

Do while <condition>

<statements>

Loop General Syntax is

General Syntax is :

Do

<statements>

Loop while<condition>

4. Ex.

Do While intNumber < 100

lblNumber.Caption=intNumber

intNumber = intNumber + 1

Loop

Ex. Dim intNum as integer

Do

Form1.print intNum

intNum = intNum +1

Loop while(intnum <= 10)

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote