once we encounter the null characterthe control jumps out of the while loop and the length is initialized with the value of note the library function strlen( which is defined in string returns the length of string programming example write program to find the length of string #include #include int main(char str[ ] lengthclrscr()printf("\ enter the string ")gets(strwhile(str[ !'\ ' ++length iprintf("\ the length of the string is % "length)getch(return output enter the string hello the length of the string is step [initializeset istep repeat step while str[ !null step if str[ >'aand str[ <' set upperstr[istr[ - else set upperstr[istr[ [end of ifset [end of loopstep set upperstr[inull step exit figure algorithm to convert characters of string into upper case converting characters of string into upperlower case we have already discussed that in the memory ascii codes are stored instead of the real values the ascii code for - varies from to and the ascii code for - ranges from to soif we have to convert lower case character into uppercasewe just need to subtract from the ascii value of the character and if we have to convert an upper case character into lower casewe need to add to the ascii value of the character figure shows an algorithm that converts the lower case characters of string into upper case note the library functions toupper(and tolower(which are defined in ctype convert character into upper and lower caserespectively in the algorithmwe initialize to zero using as the index of strwe traverse each character of str from step to if the character is in lower casethen it is converted into upper case by subtracting from its ascii value but if the character is already in upper casethen it is copied into the upperstr string finallywhen all the characters have been traverseda null character is appended to upperstr (as done in step