194k views
2 votes
"given a string variable named sentence that has been initialized, write an expression whose value is the index of the very last character in the string referred to by sentence. submit"

1 Answer

1 vote

Answer:

There are many string built-in functions which would help us to do numerous operations on the string. A person who can play with strings and Dates are the best programmers.

char[50] sentence = “This is a sentence;

print sentence[sentence.length()-1]; // expected expression

The above piece of get declares a character array and initialized with a sentence. The next sentence obtains the “last index” using “sentence. length() and subtracts 1 to get the last index of the given string and pass it to the character array. So it will print “e” since ‘e’ is the last character in the sentence.

User Ychiucco
by
5.2k points