|
-
July 15th, 2010, 06:42 AM
#1
Something about arrays
Hello I am taking a programming class and I am stuck with this part of the project. Could someone please help me out. Below is the portion I am stuck on and below that is the current code I have completed.
• Then, write the code to update every other element within the array with a lowercase x. The output should appear like the following:
PRINTING CONTENTS OF ARRAY and adding x to every other element
A x C x E x G x I x K x M x O x Q x S x U x W x Y x
• Write the code that will display only the even or odd numbered elements within the array. The output should appear as follows:
PRINTING CONTENTS OF ARRAY USING THE MOD Option
=====================================================
Even Numbered Element = 0 Contents of Element within Array is = A
Even Numbered Element = 2 Contents of Element within Array is = C
Even Numbered Element = 4 Contents of Element within Array is = E
Even Numbered Element = 6 Contents of Element within Array is = G
Even Numbered Element = 8 Contents of Element within Array is = I
Even Numbered Element = 10 Contents of Element within Array is = K
Even Numbered Element = 12 Contents of Element within Array is = M
Even Numbered Element = 14 Contents of Element within Array is = O
Even Numbered Element = 16 Contents of Element within Array is = Q
Even Numbered Element = 18 Contents of Element within Array is = S
Even Numbered Element = 20 Contents of Element within Array is = U
Even Numbered Element = 22 Contents of Element within Array is = W
Even Numbered Element = 24 Contents of Element within Array is = Y
--------------------------------CODE---------------------------------------------
#include <iostream>
using std::cin;
using std::cout;
using std::endl;
int _tmain(int argc, _TCHAR* argv[])
{
int i = 0, max = 25, num = 0;
char alphabet[26] = {'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','T','S','T','U','V','W','X','Y','Z'};
cout << "PRINTING CONTENTS OF ARRAY" << endl;
cout << "==================================" << endl;
for(i = 0; i <= max; i++)
cout << alphabet[i] << " ";
cout << endl;
cout << "This is the title to your Program related to the alphabet." << endl
<< endl
<< "Select the number that coincides with the alphabet."<< endl
<< "For example, the number 7 should display the letter G." << endl
<< endl
<< "Enter a number between 1 and 26: ";
cin >> num;
cout << endl
<< "The number you selected: " << num << endl;
num--;
cout << "The letter related to this number: " << alphabet[num] << endl;
cout << endl
<< "PRINTING CONTENTS OF ARRAY and adding x to every other element" << endl
<< "==================================" << endl;
system("pause");
//return 0;
}
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|