Q13. Write a code to find length of a string

String :- The string is defined as an array of characters. The difference between a character array and a string is the string ending with a special character ‘\0’.

For Eg :- If the string is “alfatechlab”, the output is 11.

Algorithm for find length of string

START
Step 1:Length = 0
Step 2: Repeat step 3 while S1 [Length] ≠ NULL
Step 3: Length = Length + 1
Step 4: Return Length
STOP

Code for find length of string

Output

Length of the string =11

Recommended Programs
Program to find factorial of a number
Program to count number of digits in a number