Header Ads

A program to calculate the length of strings in C

Calculating the lenth of string including yhe space value:

********************************Program************************************

#include<stdio.h>
#include<conio.h>
int main()
{
 char str[100],i=0,lenth;
 printf("\n Enter the string:");
 gets(str);
 while(str[i] !='\0')
 i++;
 lenth=i;
 printf("\n The lenth of the string is:%d",lenth);
 getch();
}

*******************************Output***************************************

Output of the program to calculate the length of strings

No comments