Google Ads

Wednesday, May 27, 2009

Length of String

LENGTH OF THE GIVEN STRING

#include”stdio.h”
#include “conio.h”
#include
void main()
{
char str[50],ch;
int i=0,c=0;
clrscr();
printf("\n\nEnter the String : ");
gets(str);
ch=str[i];
while(ch!='\0')
{
i=i+1;
ch=str[i];
c++;
}
printf("\nThe Length of the String : %d",c);
getch();
}


Output will be


Enter the String : India is my country

The Length of the String : 9

No comments:

Post a Comment