In: Computer Science
Solution
Code
#include<iostream>
using namespace std;
int main() {
char word[100], tmp;
int length = 0, i = 0;
cout << "Enter a word: ";
cin.getline(word, 100);
while (word[length] != '\0') {
length++;
}
length = length - 1;
while (i < length) {
tmp = word[i];
word[i] = word[length];
word[length] = tmp;
length--;
i++;
}
cout << "The Output is: " << word;
return 0;
}
Screenshot
Output
---
all the best