Hello, OnlineGDB Q&A section lets you put your programming query to fellow community users. Asking a solution for whole assignment is strictly not allowed. You may ask for help where you are stuck. Try to add as much information as possible so that fellow users can know about your problem statement easily.

how string works in character data type?

+1 vote
asked Mar 10, 2023 by Yammna Noor (130 points)

1 Answer

0 votes
answered Mar 10, 2023 by Peter Minarik (86,040 points)

Most languages have similar features, so I'm not going to focus on any language specifically as you didn't mention which language you're interested in.

A string is a sequence of characters, e.g.: "Hello" is a string that consists of the characters 'H', 'e', 'l', 'l', 'o'.

A string in most languages supports indexing, i.e. accessing specific parts.

E.g.:

myString = "Hello";
characterE = myString[1];

The above code gets the 1st character of the string "Hello", that is the character 'e'. In computer science indexing almost always starts from 0. So the very first letter is at index 0, the second is at index 1, etc.

If you're interested in language-specific features, share what language you'll use.

Welcome to OnlineGDB Q&A, where you can ask questions related to programming and OnlineGDB IDE and and receive answers from other members of the community.
...