String length program
#include<stdio.h>
int main()
{
//let's assume the maximum string size as 100.
//initialize length as 0. Otherwise, it will take some garbage value.
char str[100];
int i, length = 0;
//Get string input from the user
printf("Enter the string\n");
scanf("%s",str);
/*Loop through each character
and increment the length till we reach the null character. */
for(i = 0; str[i] != '\0'; i++)
length++;
//print the length
printf("Length = %d\n",length);
return 0;
}