Language: C++

#include <iostream>
#include <cstring>
#include <string>

#define MAX_LEN (1000)
#define MAX_Q   (100)

using namespace std;

int main()
{
    int    q;
    string str;

    do {
        cin >> str;
    } while (str.length() < 1 || str.length() > MAX_LEN || all_lower(str) == 0);

    do {
        cin >> q;
    } while (q < 1 || q > MAX_Q);
    
    for (int i = 0; i < q; i++) {
         int    a, b;
         string ins;
         string p;

         do {
             int num = (cin >> ins >> a >> b >> p);
         } while (a < 0 || b < 0 || a > b || b > str.length() ||
                  (ins == "replace" && b - a + 1 != strlen(p)));
                    
         if (num == 3) {
             if (ins == "print") {
                 cout << str.substr(a, b) << endl;
             } else if (ins == "reverse") {      
                 reverse(a, b);
             } 
         } else if (num == 4) {
             replace(a, b, p);
         }
    }

    return (0);
}

void all_lower(string str)#include <iostream>
#include <cstring>
#include <string>

#define MAX_LEN (1000)
#define MAX_Q   (100)

using namespace std;

void all_lower(string str);

int main()
{
    int    q;
    string str;

    do {
        cin >> str;
    } while (str.length() < 1 || str.length() > MAX_LEN);

    do {
        cin >> q;
    } while (q < 1 || q > MAX_Q);
    
    for (int i = 0; i < q; i++) {
         int    a, b;
         string ins;
         string p;

         do {
             int num = (cin >> ins >> a >> b >> p);
         } while (a < 0 || b < 0 || a > b || b > str.length() ||
                  (ins == "replace" && b - a + 1 != strlen(p)));
                    
         if (num == 3) {
             if (ins == "print") {
                 cout << str.substr(a, b) << endl;
             } else if (ins == "reverse") {      
                 reverse(a, b);
             } 
         } else if (num == 4) {
             replace(a, b, p);
         }
    }

    return (0);
}

{
     int i;

     for (i = 0; str[i] != '\0'; i++) {
          if (str[i] < 'a' || str > 'z') {
              break;
          }
     }

     if (str[i] == '\0') {
         return (1);
     } else {
         return (0);
     }
}
    

Compiler output:
a.cc:47:27: error: stray '#' in program
   47 | void all_lower(string str)#include <iostream>
      |                           ^
a.cc: In function 'int main()':
a.cc:17:60: error: 'all_lower' was not declared in this scope
   17 |     } while (str.length() < 1 || str.length() > MAX_LEN || all_lower(str) == 0);
      |                                                            ^~~~~~~~~
a.cc:29:46: error: cannot convert 'std::basic_istream<char>' to 'int' in initialization
   29 |              int num = (cin >> ins >> a >> b >> p);
      |                        ~~~~~~~~~~~~~~~~~~~~~~^~~~~
      |                                              |
      |                                              std::basic_istream<char>
a.cc:31:60: error: cannot convert 'std::string' {aka 'std::__cxx11::basic_string<char>'} to 'const char*'
   31 |                   (ins == "replace" && b - a + 1 != strlen(p)));
      |                                                            ^
      |                                                            |
      |                                                            std::string {aka std::__cxx11::basic_string<char>}
In file included from /usr/include/c++/14/cstring:43,
                 from a.cc:2:
/usr/include/string.h:407:35: note:   initializing argument 1 of 'size_t strlen(const char*)'
  407 | extern size_t strlen (const char *__s)
      |                       ~~~~~~~~~~~~^~~
a.cc:33:14: error: 'num' was not declared in this scope; did you mean 'enum'?
   33 |          if (num == 3) {
      |              ^~~
      |              enum
a.cc:37:18: error: 'reverse' was not declared in this scope
   37 |                  reverse(a, b);
      |                  ^~~~~~~
a.cc:40:14: error: 'replace' was not declared in this scope
   40 |              replace(a, b, p);
      |              ^~~~~~~
a.cc: At global scope:
a.cc:47:28: error: expected initializer before 'include'
   47 | void all_lower(string str)#include <iostream>
      |                            ^~~~~~~
a.cc:58:5: error: redefinition of 'int main()'
   58 | int main()
      |     ^~~~
a.cc:10:5: note: 'int main()' previously defined here
   10 | int main()
      |     ^~~~
a.cc: In function 'int main()':
a.cc:77:46: error: cannot convert 'std::basic_istream<char>' to 'int' in initialization
   77 |              int num = (cin >> ins >> a >> b >> p);
      |                        ~~~~~~~~~~~~~~~~~~~~~~^~~~~
      |                                              |
      |                                              std::basic_istream<char>
a.cc:79:60: error: cannot convert 'std::string' {aka 'std::__cxx11::basic_string<char>'} to 'const char*'
   79 |                   (ins == "replace" && b - a + 1 != strlen(p)));
      |                                                            ^
      |                                                            |
      |                                                            std::string {aka std::__cxx11::basic_string<char>}
/usr/include/string.h:407:35: note:   initializing argument 1 of 'size_t strlen(const char*)'
  407 | extern size_t strlen (const char *__s)
      |                       ~~~~~~~~~~~~^~~
a.cc:81:14: error: 'num' was not declared in this scope; did you mean 'enum'?
   81 |          if (num == 3) {
      |              ^~~
      |              enum
a.cc:85:18: error: 'reverse' was not declared in this scope
   85 |                  reverse(a, b);
      |                  ^~~~~~~
a.cc:88:14: error: 'replace' was not declared in this scope
   88 |              replace(a, b, p);
      |              ^~~~~~~
a.cc: At global scope:
a.cc:95:1: error: expected unqualified-id before '{' token
   95 | {
      | ^