Edit programs for money

I will have $5 paypaled for each program that is modded. Here is one of them. Shouldn't be hard at all for you programmers:


#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 << "\n\n";
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 << "\nThe final array is:\n\n";
for (index = 0; index < 26; index++)
{
cout << stuff [index];
}
}

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]);
I'll do it for USD 300.
Topic archived. No new replies allowed.