What is the incorrect action and why does it occur?

Specification: Write out Hello World twenty-five times. Each hello begins a new line.
```
#include
using namespace std;
int main()
{
int i = 1;
while(i < 25)
cout << “\nHello World”;
++i;
return 0;
}
```


There are two errors in this code. First, the initial value of i = 1, and the condition statement is running while i < 25. This will result in 24 Hello Worlds, not 25.

However, the real problem is that the while loop does not have { }; therefore, only the cout statement will be performed. The value of i is never incremented.

The fix involves inserting { } and initially setting i to zero.

Computer Science & Information Technology

You might also like to view...

A void function

a) performs some action and returns a value b) performs some action but does not return a value c) is a statement d) call is written much like a call to a value returning function but is terminated with a semicolon. e) A void function may have a return statement but is not required to have one.

Computer Science & Information Technology

Which of the following is not a component of a digital certificate?

(a) The subject’s public key. (b) A serial number and expiration date. (c) The hash function used to encrypt the message (d) The signature of a trusted certification authority.

Computer Science & Information Technology

You can use __________________ in Windows 8.1 to access files and folders.

Fill in the blank(s) with the appropriate word(s).

Computer Science & Information Technology

A new LAN switch is installed with on fiber ports. Which of the following would a technician need on the new switch to allow compatibility to the existing fiber network?

A. Router B. Repeater C. Media converter D. Hub

Computer Science & Information Technology