C program to find length of a string using while Loop.












C program to find length of a string using while Loop.




C program to find length of a string using while Loop.



#include <stdio.h> #define MAX 200 int main() { char text[MAX]; int count= 0; printf("\n Enter any string: "); gets(text); while(text[count] != '\0') { count++; } printf("Length of enter string '%s' = %d", text, count); return 0; }


Output:
Enter any string: c language Length of enter string 'c language' = 10




Exercise: 1
Write a C program to find length of a string.