Here is one in C
Code:
#include <stdio.h>
#include <string.h>
#include <ctype.h>
#define LENGTH 256
int main()
{
char alphabet[] = {'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I',
'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R',
'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', '\0'};
char message[LENGTH +1], temp;
int i;
printf("Enter a string: ");
fflush(stdout);
fgets(message, LENGTH, stdin);
message[strlen(message) -1] = '\0'; /* remove '\n' from string */
message[0] = toupper(message[0]);
printf("After capitalizing the first letter of this string it becomes: %s\n",
message);
message[strlen(message) -1] = toupper(message[strlen(message) -1]);
printf("After capitalizing the last letter of this string it becomes: %s\n",
message);
for(i=0; i < alphabet[i]; ++i)
if(message[0] == alphabet[i])
{
message[0] = alphabet[(i+3)%strlen(alphabet)];
break;
}
printf("After adding three to the first letter of this string it becomes: %s\n",
message);
temp = message[0];
message[0] = message[strlen(message) -1];
message[strlen(message) -1] = temp;
printf("After swapping the first and last letters of this string it becomes: %s\n",
message);
return 0;
}
But since you're looking at C++, you might want to use some nifty string functions.