property of a
containing the input so far - and a
can be treated as an array of characters:
string greeting = "Hello World";
Will print the first letter of each word:
So to find out how many times a character is repeated at the beginning of a string is simple:
1) Create a variable to hold the "compare character" - call it
to the first character in the string
3) Create a variable to hold the identical values count called
, set it to zero.
4) Use a
loop to look at each character in the string.
4.1) If the character is not the same as
, exit the loop using
4.2) Otherwise, increment
5) After the loop,
will contain the number of identical characters at the beginning of the string.