// This program is calling a function to calculate the length of any String up to 256 charachter.
#include <iostream>
using namespace std;
//Function declaration
int sLength ( int );
main( )
{
int c;
cout<<"Enter any string: ";
cout << "\n No. of digits in given number is: " << sLength(c);
}
// function to calculate the length of string
int sLength ( int str )
{
int i,count=0;
char ch[256];
gets(ch);
for(i=0;ch[i]!='\0';i++)
{
count++;
}
return count;
}
#include <iostream>
using namespace std;
//Function declaration
int sLength ( int );
main( )
{
int c;
cout<<"Enter any string: ";
cout << "\n No. of digits in given number is: " << sLength(c);
}
// function to calculate the length of string
int sLength ( int str )
{
int i,count=0;
char ch[256];
gets(ch);
for(i=0;ch[i]!='\0';i++)
{
count++;
}
return count;
}
No comments:
Post a Comment