I am new to programming and I have to write a function string middle (string str) that returns a string containing the middle character in str if the length of str is odd, or the two middle characters if the length is even. For example, middle ("middle") returns "dd".

I have no idea what I am doing or even how to start. Please please please help me!
Start with writing the function for the situation when the string is empty.:)
I'm not even sure how to even start. I am terrible at programming.

Place function header here

   call the function

using the string library to determine its length
use modulus operator to determine if it is odd or even
use integer division and addition to find the strings middle
return the character string[middle]
use methods above to find the middle two characters
return first middle char + second middle char

Does that make sense?
Topic archived. No new replies allowed.