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
|
// Arrays and Pointers program for Assignment week 4
#include<iostream>
#include<iomanip>
using std::cin;
using std::cout;
using std::endl;
using std::setw;
int main()
{
char* pletter2[]= { "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" };
char* pphrase = "PRINTING CONTENTS OF THE ARRAY";
char* pphrase2 = "==============================";
char* pphrase3 = "PRINTING CONTENTS OF THE ARRAY and adding x to every other element";
char* pphrase4 = "==================================================================";
char* pphrase5 = "x";
int number = 0;
int i;
cout<<endl;
cout <<pphrase;
cout <<endl;
cout <<pphrase2;
cout <<endl;
for(int i = 0; i < 26; i++)
{
cout <<pletter2[i];
}
cout <<endl;
cout <<endl;
cout <<"Please enter a number between 1 and 26 that corresponds to a letter in the alphabet: "<<endl;
cout <<endl;
cout <<"Example: The number 10 corresponds to the letter J."<<endl;
cin >>number;
if ( number >=1 && number <=26)
{
cout <<"The number you selected is: "<<number<<endl;
cout <<"The letter that corresponds with that number is: "<<pletter2[number-1]<<endl;
}
else
{
cout<<"There was an error with your input please try again"<<endl;
}
{
int j = 0;
cout <<endl;
cout << pphrase3;
cout <<endl;
cout <<pphrase4;
cout <<endl;
for(j = 1; j <= 26; j = j +2)
{
pletter2[j] = pphrase5;
cout <<pletter2;
}
return 0;
}
|