title: changing case for first and last letter C++
body: <p>i need ThE FirsT AnD LasT letter of every word to be uppercase and the rest lowercase but function convertFirstAndLastLetter only does the first and last of the sentence.   </p>
  
  <pre><code>void convertFirstAndLastLetter(char wrd[]) 
  {
      size_t last = strlen(wrd) - 1;
      size_t first = 0;
  
      wrd[first] = toupper(wrd[first]);
      wrd[last] = toupper(wrd[last]);
  
      for(int i = first + 1 ; i &lt; last - 1; i++)
      {
          wrd[i] = tolower(wrd[i]);
      }
  }
  
  int main ()
  {
      float val;
      cout &lt;&lt; "ent ";
      cin &gt;&gt; val;
  
      if (val == 4)
      {
          char wrd[256];
          cin.ignore();
          cin.getline(wrd,256);
          convertFirstAndLastLetter(wrd);
          cout &lt;&lt; wrd;
  
          return 0;
      }
  }
  </code></pre>