I am trying to do my homework and I have a problem. My homework
β’ Using the for loop, print the contents of the array.
The output should look like this:
PRINTING MASS CONTENTS
ABCDEFGH I JKLMNOPQRSTUVWXYZ
I have a code and it works. However, at the end of my alphabet a bunch of random characters and characters appear. Is there something that you guys see that I'm doing wrong?
Here is my code.
#include <iostream> using std::cin; using std::cout; using std::endl; // main FUNCTION BEGIN PROGRAM EXECUTION int main() { // ALPHABET ARRAY DECLARATIONS char Letters [26] = { 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z'}; for (int i = 0; i < 27 ; i++) { cout<< "PRINTING CONTENTS OF ARRAY" << endl; cout<< "===============================" << endl; cout<< Letters << " "; cout<< endl; break; } return 0 ; } // ***END main FUNCTION***
Basically the problem is that it prints AZ as I want, but also prints a bunch of random characters after Z. Any ideas? Since I'm new to this, I'm sure this is probably something simple. Thanks in advance!