How to reverse a string in c++ using while loop
#include <iostream>
using namespace std;
int main() {
 
  string greeting = "Hello";
  int len = greeting.length();
  int n = len-1;
  int i = 0;
  while(i<=n){
    //Using the swap method to switch values at each index
    swap(greeting[i],greeting[n]);
    n = n-1;
    i = i+1;
  }
  cout<<greeting<<endl;
}