helpp please :(

hii so i had an in class quit the other day and the question was to write a program which when it is given a word if the word has even number of letters it switches the two middle letter with each other for exacmple SEAN would be SAEN and if it is a word with odd number of letters move the middle letter to the end of the word for example MAN would be MNA . please help me with the syntax , this is what i have written on the test. please help me make it work.
#include <iostream> // basic input output library

#include <string.h> // the string library

using namespace std ;

int main () {

int i; // stores the middle of the word

int wlengh; //stores the lengh of the given string

string word; // stores the given string

string mo ;// stored the modified word

string t ;

char a ; //stores the middle character

char b; // stores the one before middle character

cout << "welcome to word swap, please enter ONE word: ";

cin >> word;

wlengh=word.lengh; //finds the lenght of the given word and stores it in wlengh

if (wlenght %2 ()==0 ) { //if statement checking wether it is an even or odd lengh
// since while checking the lengh it starts from 0 if the
// word has even lengh the word has odd number of letters.

b=word[i-1]; // find the character in word before the middle


erase.b in word //supposed to erase the middle one in the original one


mu=word += b // adds the middle character to the end

}

else {

b=word[i-1]; //stores the one before middle in word in char b

a=word[i] //stores the middle character in word in char a

// here is need to put something that will wap places of char a and b but i cannot work out the sytaxt

}

cout << mu ;

cout << "type * to stop";

cin << t ;

if (t.compare("*"){

cout << "thank you for using my program :)" ;

}
Topic archived. No new replies allowed.