1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83
|
#include <iostream>
using std::cin;
using std::cout;
using std::endl;
int main()
{
char letters [] = { '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', '\0' } ;
cout << "PRINTING CONTENTS OF ARRAY" << endl;
cout << "==================================" << endl;
for (int i = 0; i <= 0; ++i)
{
cout << letters << " ";
}
cout << endl;
cout << endl;
cout << "This is the title to your Program related to the alphabet." << endl;
cout << endl;
cout << "Select the number that coincides with the alphabet." << endl;
cout << endl;
cout << "For example, the number 7 should display the letter G." << endl;
cout << endl;
cout << "Enter a number between 1 and 26: ";
int number;
cin >> number;
cout << endl;
cout << "The number you selected: " << number << endl;
if ((number > 0) && (number <= sizeof(letters)))
{
cout << "The letter related to this number: " << letters[number-1] << endl;
}
else
{
cout << "Sorry, you must choose a number between 1 and 26." << endl;
cout <<endl;
}
cout << "PRINTING CONTENTS OF ARRAY and adding x to every other element" << endl;
cout << "===============================================================" << endl;
int j=0;
for (int i = 1; i < 2; i+=2) {
letters[i] = 'x';
for(int j = 0; j < 26; j+=2)
cout << letters[j] << letters [i];
cout << endl;
}
cout << "PRINTING CONTENTS OF ARRAY USING MOD OPTION" << endl;
cout << "===========================================" << endl;
system ("pause");
return 0;
}
| |