#include<iostream>
using namespace std;
int lon(char a[][30],int);
int main()
{
char a[10][30];
int m,i;
cout<<"Enter num of strings:";
cin>>m;
cout<<"\nEnter the strings:\n\n";
for(i=0;i<=m;++i)
{
cin.getline(a[i],30);
}
cout<<"The result is: "<<lon(a,m);
return 0;
}
int lon(char a[][30],int m)
{
int max,i;
max=strlen(a[0]);
for(i=0;i<=m;++i)
{
if(max<strlen(a[i]))
max=strlen(a[i]);
}
return max;
}
using namespace std;
int lon(char a[][30],int);
int main()
{
char a[10][30];
int m,i;
cout<<"Enter num of strings:";
cin>>m;
cout<<"\nEnter the strings:\n\n";
for(i=0;i<=m;++i)
{
cin.getline(a[i],30);
}
cout<<"The result is: "<<lon(a,m);
return 0;
}
int lon(char a[][30],int m)
{
int max,i;
max=strlen(a[0]);
for(i=0;i<=m;++i)
{
if(max<strlen(a[i]))
max=strlen(a[i]);
}
return max;
}
0 comments:
Post a Comment