I have 5 programs due real soon. I need to get them done so I can pass. I will paypal $5 for each program that is modded correctly. Here is ONE of them:
#include <cstdlib>
#include <iostream>
using namespace std;
/*
This program fills a character array with the letters A through Z.
It then sets every n’th value (where n is user entered) to an
asterisk. Finally, the user specifies two indexes in the array to
be swapped. The final array is printed.
Programmer: Your name here
Date: Current date here
*/
void fill_array (char stuff [26]);
void print_array (char stuff [26]);
int main(int argc, char *argv[])
{
char my_array [26]; // array of characters to be manipulated
int n, // every n’th value in array is set to
// an asterisk (user entered)
swap1, // indexes in the array to be swapped
swap2; // (user entered)
fill_array (my_array);
cout << "Enter an integer (every nth element will be set to an *): ";
cin >> n;
asterisk_array (my_array, n);
cout << "Enter two indexes in the array to swap: ";
cin >> swap1 >> swap2;
swap_array (my_array, swap1, swap2);
print_array (my_array);
cout << "
";
system(“PAUSE”);
return EXIT_SUCCESS;
}
// fill_array sets the values in the array to the user case alphabet
void fill_array (char stuff [26])
{
int index; // index in the array (element to set)
char ch = ‘A’; // character to be placed in the array
for (index = 0; index < 26; index++)
{
stuff [index] = ch;
ch++;
}
}
// print_array prints the character array
void print_array (char stuff [26])
{
int index; // index in the array (element to print)
cout << "
The final array is:
";
for (index = 0; index < 26; index++)
{
cout << stuff [index];
}
}
-
Write the <b>function prototype</b> and <b>function definition</b> for the function <b>asterisk_array</b>. It sets every <b>n’th</b> element in the array to an <b>asterisk character</b>.
-
Write the <b>function prototype</b> and <b>function definition</b> for the function <b>swap_array</b>. It swaps the elements in the array at the two indexes entered by the user.
Test your program.
3. Change the call to fill_array in mainto:
fill_array (my_array [26]);