My code is set up so that a user enters however big they need an array to be and can then choose from characters letters or special symbols. It then takes that input and tells you what each and everything you enter is. For example if you enter AsDf12@# It will say A is a cap s is a lower D is a cap 1 is a digit @ is a special and so on. It then Will reverse the input and change all capitals to lower case so the example above would be #@21FdSa. And Lastly I am supposed to shift all elements of the array 2 spaces to the left. Ie 54321 would become 32154. I have no idea how to shift an array. Any help would be greatly appreciated
#include <iostream>
usingnamespace std;
int main()
{
int N; // This will be the number the user enters for size of array
char choice; // Choice on if they wish to select another array
cout << "This is an array manipulation program" << endl;
cout << "\nEnter the size of the array ";
cin >> N;
char array[N]; // This is the array that will store all the inputs
do
{
cout << "\nEnter any " << N << " Characters, Digits, or Special Symbols : ";
for(int i=0; i <N; ++i)
{
cin>>array[i];
}
cout << "\n\nThe array contains the following : ";
for(int i=0; i<N; i++)
{
cout<<array[i];
}
cout << endl;
bool CapitalExists=false; // this checks if Capital Letters Exist
bool lowerExists=false; // This checks if small letters exist
bool digit=false; // This checks if the input is a digit
bool special=false; // This checks if the input is a special symbol
for(int i=0; i<N; i++)
{
if (array[i]>= 'A' && array[i]<= 'Z')
{
CapitalExists=true;
cout << array[i] << " is a Capital Letter" <<endl;
}
elseif(array[i]>='a' && array[i]<='z')
{
lowerExists=true;
cout << array[i] << " is a Small Letter" <<endl;
}
elseif(array[i]>=48 && array[i]<=57)
{
digit=true;
cout << array[i] << " is a Digit" <<endl;
}
else
{
special=true;
cout << array[i] << " is a Special Symbol" <<endl;
}
}
if(!CapitalExists)
cout<<"\n\nThere are no capital letters in the array \n" <<endl;
if(!lowerExists)
cout<<"\n\nThere are no small letters in the array \n" <<endl;
if(!digit)
cout<<"\n\nThere are no digits in the array \n" <<endl;
if(!special)
cout<<"\n\nThere are no Special Symbols in the array \n" <<endl;
cout << "\n\n\nThe array in reverse order ";
for(int i=N-1; i>=0;i--)
{
cout<<array[i];
}
cout << "\n\nThe array after converting Capital Letters \nto Small Letters"
<< " and Vice Versa : ";
for(int i=N-1; i>=0;i--)
{
if(array[i]>='A' && array[i]<='Z')
cout<<char(array[i]+=32);
elseif(array[i]>='a' && array[i]<='z')
cout<<char(array[i]-=32);
else cout <<array[i];
}
cout << "\n\nWould you like to check for another array?"
<< "\nEnter Y or y for Yes \nOR\nN or n for No -------> ";
cin >> choice;
while (choice != 'y' && choice != 'Y' && choice != 'N' && choice != 'n')
{
cout << "Invalid Character, Enter Y, or y, or N, or n"
<< " -----> ";
cin >> choice;
}
}
while (choice != 'n' && choice != 'N');
cout << "\n\nProgram is terminated" << endl;
cout << "\nThis Algorithm Designed and Implemented by\n"
<< "Bob Dylan - Analysis Data Group\nOctober 30 - 2015" <<endl;
return 0;
}
But How can i do that if the user can enter any number?
They enter the size of the array at array[N]
I could declare arrayname[10] and they could just enter arrayname[11]
I need it so that whatever they enter shifts 2 to the left. Or is what you just said exactly what im supposed to do hahah