C program to find the length of a string.

 

01 #include <stdio.h>
02
03 int main()
04 {
05 char str[20];
06 int i=0;
07 int len=0;
08
09 printf("Enter any string - ");
10 gets(str);
11
12 while(str[i]!='')
13 {
14 i++;
15 len++;
16 }
17
18 printf("Length of the string is - %d n",len);
19
20 return 0;
21 }
 
OUTPUT :

Enter any string - Hello World
Length of the string is - 11

Related Post

Leave a Reply

Your email address will not be published. Required fields are marked *


The reCAPTCHA verification period has expired. Please reload the page.