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

I am confused i dont know how to begin Write a c++ program that creates vector N

ID: 3816424 • Letter: I

Question

I am confused i dont know how to begin

Write a c++ program that creates vector N random ASCII characters (note the corresponding equivalent ASCII code range from 26 to 132), and then sorts the random characters into alphabetical order and also in reverse alphabetical order. Your code should create a random number vector with a minimum of 26 and maximum of 132, then convert the random numbers to random characters, then put the random number vector into rising/falling order, and then finally convert the rising/falling numerical order to alphabetical and reversed alphabetical order. Note this will require double for loops in your program.

Explanation / Answer

#include <cstdlib>
#include <ctime>
#include <iostream>

using namespace std;

int main()
{

//integer array taken
int arr[10];
//character array taken to store integer array
char ch[10];

srand((unsigned)time(0));
//Random numbers generated
for(int i=0; i<10; i++)
   {
arr[i] = (rand()%100)+26;

cout << arr[i] << endl;
}

//Numbers are sorted

for (int i = 0; i < 10; ++i)
for (int j = 0; j < 10 - i - 1; ++j)
if (arr[j] > arr[j + 1])
{
int temp = arr[j];
arr[j] = arr[j + 1];
arr[j + 1] = temp;
}
  
cout<<"Sorted array is"<<endl;
  
for(int i=0; i<10; i++)
   {
  

cout << arr[i] << endl;
}

//sorted integer array assigned to character array

for(int i=0; i<10; i++)
   {
  
ch[i]=(char) arr[i];
  
}

cout<<"Sorted Character Array in Alphabetical Order is"<<endl;

for(int i=0; i<10; i++)
   {
  
cout << ch[i] <<" ";
}

cout<<endl<<endl;

cout<<"Sorted Character Array in Reverse Alphabetical Order is"<<endl;

for(int i=10-1; i>=0; i--)
   {
  
cout << ch[i] <<" ";
}


return 0;
}