Thursday, 20 March 2014

PROGRAM IN C++ TO READ A STRING AND SHOW THE LENGTH OF STRING…


#include<iostream.h>                                               //cout,cin, << , >>
#include<conio.h>
#include<string.h>                                                  //for strlen()
#include<stdio.h>                                                  //for gets() and puts()
/*..Main Function Start’s…*/
void main()
{
char string[50];
int length;
clrscr();
cout<<”\n enter a string in minimum 50 characters:”;
gets(string);
length=strlen(string);
puts(string);
cout<<”\n the length of the string is:”<<length<<”\n”;
getch();
}
/*..Main Function End’s….*/

THE OUTPUT IS

Image

No comments:

Post a Comment