Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

I have posted this question earlier but my question wasnt addressed: The Followi

ID: 3758512 • Letter: I

Question

I have posted this question earlier but my question wasnt addressed: The Following is the Assignment, I will also post my code semi completed. After checking the code I have a problem with the last # which is 9. I need help on how to fix the rotation to the left. If you may please explain the changes in comments for better understanding. Please keep it at an Introduction to programming level I will get a zero if I use something we have yet to discuss. ASSIGNMENT: Write a C++ program that manipulates an array of characters. The function of the program is to define a character array of size N. The size of the array is entered from the keyboard by the user. The program then performs the following operations :1.Allow the user to populate the array by entering N characters from the key board. 2. Display the entire array. 3. Display all capital letters or none in the array. 4. Display all small letters or none in the array. 5. Display all digits or none in the array. 6. Display all special symbols or none in the array. 7.Reverse the order of the element of the array then display the array. 8.Convert all small letters to capital letters and vice versa , then display the array. 9. Rotate all the elements of the array 2 positions the left. Repeat Steps 1 thru 9 until the user enters N or n in order to terminate MY CODE: #include using namespace std; int main() { int arraysize; char choice; bool check = false; cout << "This is an array manipulation program" << endl; cout << "Enter the size of the array "; cin >> arraysize; do { cout << "Enter any " << arraysize << "Characters, Digits , Special Symbols : "; char characters [arraysize]; int i; for (i=0 ; i> characters [i]; } cout << " The Array Contain The following: "; for (i=0; i= 65 && characters[i] <= 90 ) { cout << characters[i] << " is a Capital Letter" << endl; check = true; } } if (check == false) { cout << " There are no Capital Letters in this Array " << endl; } check = false; for (int i=0; i= 97 && characters[i] <= 122) { cout << characters[i] << " is a Small letter" << endl; check = true; } } if(check == false) { cout << "There are No Small Letters in this Array " << endl; } check = false; for (int i=0; i= 48 && characters[i] <= 57) { cout << characters [i] << " is a Digit" << endl; check = true; } } if (check == false) { cout << "There are No Digits in this Array " << endl; } check = false; for(int i=0; i= 33 && characters[i] <= 47) || (characters[i] >= 58 && characters[i] <= 64)) { cout << characters[i] << " is a Special Symbol" << endl; check = true; } } if (check == false); { cout << " There are No Special Symbols in this Array" << endl; } cout << " The Array in Reverse Order "; for (int i= arraysize-1; i >= 0; i--) { cout << characters[i]; } cout << " The Array after converting Capital to Small Letters" << " and Vice Versa "; for(int i=arraysize-1; i >= 0; i--) { if (characters[i] >= 65 && characters[i] <= 90 ) { static_cast (characters[i]) + 32; cout << static_cast ((characters[i]) + 32); } else if (characters[i] >= 97 && characters[i] <= 122) { static_cast (characters[i]) - 32; cout << static_cast ((characters[i]) - 32); } else cout << characters[i]; } cout << " The Array After Rotating 2 positions to the left "; for (int i = arraysize-1; i >= 0; i--) { cout << characters[i] - 2; } cout << " Would you like to Check another Array " << endl; cout << "Enter Y or y For YES " << endl; cout << "OR " << endl; cout << "N or n For NO -------> "; cin >> choice; cout << " "; while (choice != 'y' && choice != 'Y' && choice != 'n' && choice != 'N') { cout << "Invalid Character, Enter Y, or y, or N, or n ------> "; cin >> choice; } } while (choice == 'Y' || choice == 'y'); cout << " Program is Terminated " << endl; cout << "This Algorithm Designed and Implemented by" << endl; cout << "Melissa Villatoro - Analysis Data Group" << endl; cout << "October 30 - 2015" << endl; } PLEASE EXCUSE MY FORMAT I TRIED MY BEST TO PUT IT AS I HAVE IT

Explanation / Answer

Try this code:

// a program to find the total values of an

// array y by passing an array to a function using pointer

#include <iostream>

#define n 7

using namespace std;

// a function prototype

int get_total(int*, int);

int main()

{

        int total, y[n]={6,9,2,4,5,23,12};

        cout<<" Calling function get_total(y, n),";

        cout<<" By bringing along the value of y, an array";

        cout<<" first address and n = 7, an array size.";

        cout<<" An array name, is the pointer to the";

        cout<<" 1st element of an array ";

        // function call, pass along the pointer to the first

        // array element and the array size, and the

        // return result assign to variable total

        total = get_total(y, n);

        cout<<" Sum of the 7 array elements is "<<total<<endl;

        return 0;

}

// a function definition

int get_total(int *ptr, int x)

{

        int i, total = 0;

        // do the looping for array elements...

        for(i=0; i<x; i++)

        {

                // displays the array content, pointed by pointer...

                cout<<*(ptr+i)<<" ";

                // do the summing up of the array elements...

                total += *(ptr+i); //total=total + *(ptr+i);

        }

        // return the result to the calling program...

        return total;

}

[bodo@bakawali ~]$ g++ gccarray.C -o gccarray

[bodo@bakawali ~]$ ./gccarray

Calling function get_total(y, n),

By bringing along the value of y, an array

first address and n = 7, an array size.

An array name, is the pointer to the

1st element of an array

6 9 2 4 5 23 12

Sum of the 7 array elements is 61

[bodo@bakawali ~]$