What is the incorrect action and why does it occur?

Specification: Fill a character array with the uppercase alphabet (place A in [0], B in [1], etc.).
```
#include
using namespace std;
int main()
{
char alphabet[26];
int i;
for(i = 0; i< 26; ++i)
{
alphabet[i] = i;
}
return 0;
}
```

To put chars values into alphabet, need to remember chars are stored as ASCII integer codes. To fix this assignment, the integer must be offset to the ASCII 65 (for A) and cast into a char. Two fixes are shown here.
```
for(i = 0; i < 26; ++ i)
{
alphabet[i] = static_cast (i + 65);
}

or

for(i = 65; i < 91; ++ i)
{
alphabet[i] = static_cast( i ) ;
}
```

Computer Science & Information Technology

You might also like to view...

On the Home tab, the Format Painter is found under the ________ group

A) Paragraph B) Font C) Editing D) Clipboard

Computer Science & Information Technology

When must a program explicitly use the this reference?

a. Accessing a private variable. b. Accessing a public variable. c. Accessing a local variable. d. Accessing an instance variable that is shadowed by a local variable.

Computer Science & Information Technology