solidcrowd
10+ year member
CarAudio.com Elite
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
#include
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
cin >> n;
asterisk_array (my_array, n);
cout
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
{
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
for (index = 0; index
{
cout
}
}
1. Write the function prototype and function definition for the function asterisk_array. It sets every n’th element in the array to an asterisk character.
2. Write the function prototype and function definition for the function swap_array. 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]);
#include
#include
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
cin >> n;
asterisk_array (my_array, n);
cout
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
{
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
for (index = 0; index
{
cout
}
}
1. Write the function prototype and function definition for the function asterisk_array. It sets every n’th element in the array to an asterisk character.
2. Write the function prototype and function definition for the function swap_array. 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]);
