Monday, October 17, 2011

C++ program to calculate length of a string


//C++ program to calculate the length of the string
#include<iostream.h>
#include<conio.h>
#include<stdio.h>
void main()
{
clrscr();
int i;
char string[20];
cout<<"Enter A String\n";
gets(string);
for(i=0;string[i]!='\0';i++);
cout<<"The length of the string is"<<i;
getch();
}

Output:


No comments:

Post a Comment