Given a list of words, find the most common initial character and other statistics 20 different words are inputted using a string array.

A C++ program to display the alphabet which has occurred the maximum number of times as starting letter of a word in the list,and how many times it has occurred.

In this program i have also displayed a few other things too,like the longest length,shortest length,average length,maximum number of vowels,letter ending with s.

I would like to know how this program can be written more 'intelligently'.

#include&lt;iostream.h&gt;
#include&lt;string.h&gt;
int main()
{
int i,n,len=0,sum=0,j,max,min,c=0,c2=0,k=0;
int maxo=0,len1,maxi=0,c1=0,len2,counter=0,maxo1=0,len3;
 float avg;
char list[100][100] = { 0 };
char vow[] = "AEIOUaeiou";
char letter;
for(i=0;i&lt;2;i++) 
{
cout&lt;&lt;"Enter word:  ";
gets(list[i]);

len=strlen(list[i]);                                
sum=sum+len;
cout&lt;&lt;"Length of word:  "&lt;&lt;len&lt;&lt;endl;
if(list[i][len-1]=='s')
{cout&lt;&lt;"The Word "&lt;&lt;list[i]&lt;&lt;" ends with s"&lt;&lt;endl;
 c2++;
 }

}
//Word input by user.Prints word along with length.       
min=strlen(list[0]);
max=strlen(list[0]);
//Initialising max and min.
for(i=0;i&lt;2;i++)
 {
   if(strlen(list[i])&lt;min)
   {min=strlen(list[i]);}
    if(strlen(list[i])&gt;max)
    {max=strlen(list[i]);}

     }
  for(i=0;i&lt;2;i++)
  {
  if(max==strlen(list[i]))
  cout&lt;&lt;"The max value of the lengths stored:"&lt;&lt;list[i]&lt;&lt;endl&lt;&lt;"Word count:"
  &lt;&lt;max&lt;&lt;endl;               
  if(min==strlen(list[i]))
  cout&lt;&lt;"The min value of the lengths stored:"&lt;&lt;list[i]&lt;&lt;endl&lt;&lt;"Word count:"
  &lt;&lt;min&lt;&lt;endl;
  }
//Max and Min value of string lengths are printed.
 avg=sum/2; 
 cout&lt;&lt;"Avg length:"&lt;&lt;avg&lt;&lt;endl;
 //Average value printed.
 cout&lt;&lt;"The number of words with s:"&lt;&lt;c2&lt;&lt;endl;
//Word ending with s.


 for (i = 0; i &lt;2; i++) 

 {len1 = strlen(list[i]);
 for (k = 0; k &lt; len1; k++) 
 {
    for (j = 0; j &lt; strlen(vow); j++)
        //if (list[j][k] == vow[j])
        if (list[i][k] == vow[j])
            c++;
}
cout &lt;&lt; "Number of vowels in line " &lt;&lt; i &lt;&lt; ": " &lt;&lt; c &lt;&lt; '\n';
if (c&gt;maxo) maxo = c;
c = 0;
cout &lt;&lt; "Maximum Vowel count so far:" &lt;&lt; maxo &lt;&lt; "\n\n";

 cout &lt;&lt; "Maximum Vowel count:" &lt;&lt; maxo &lt;&lt; endl;
   }


 //Vowel maximum count 



 for(i = 0 ;i &lt; 2 ;i++)
 { len3 = strlen(list[i]);
    letter = list[i][0];
 {for(j=0;j&lt;len3;j++)
  if(list[i][j]==letter)
   counter++;

 }
 cout &lt;&lt; "Number of identical letters as  first letter in line " &lt;&lt; i &lt;&lt; ": " &lt;&lt; counter &lt;&lt; '\n';
if (c&gt;maxo1) maxo1 = counter;
counter = 0;
cout &lt;&lt; "Maximum letter count so far:" &lt;&lt; maxo1 &lt;&lt; "\n\n";

 cout &lt;&lt; "Maximum letter count:" &lt;&lt; maxo1 &lt;&lt; endl;
   }





fflush(stdin);
getchar();
return 0;
}
Here are things I see:

Old Headers

#include&lt;iostream.h&gt;


iostream.h should be replaced with the modern day iostream. You can also consider replacing string.h with cstring. When you do this, you have to prefix all functions/classes from the standard library with std::. using namespace std; may seem shorter, but it is best avoided.



Indentation

int main()
{
int i,n,len=0,sum=0,j,max,min,c=0,c2=0,k=0;


You don't seem to have any sort of indentation set up in your main function. Pick some length, such as 4 spaces or a tab, and use it consistently. Indentation makes code easier to read.



Waaaaaaay too many variables in one place

int i,n,len=0,sum=0,j,max,min,c=0,c2=0,k=0;
int maxo=0,len1,maxi=0,c1=0,len2,counter=0,maxo1=0,len3;


This honestly looks horrible at first glance. Declaring variables at the beginning of a function is not something C++ requires. I suggest you move all of these variables close to where they are used, and use initialization instead of separate declaration and definition. For example:

len=strlen(list[i]);


Can be replaced with:

std::size_t len=strlen(list[i]);




Usage of C Style Multidimensional Arrays

char list[100][100] = { 0 };


C style multidimensional arrays are error prone, don't know their own size, and can easily decay to pointers. As such, they are best avoided. Consider using a std::arrays of std::strings, which are more versatile and less error prone.



Usage of C Style Strings

char vow[] = "AEIOUaeiou";


If you are using C++, then why are you using C style strings? Switch over to the much better std::string.



NEVER use gets

gets(list[i]);


This Stack Overflow answer tells you all you need to know. When you start using std::string, then use getline to read in a string.



Don't use endl unless you want to flush the output

... &lt;&lt; endl;


Most people don't know when starting C++ that endl unnecessarily flushes the output. Switch over to \n.



Don't use strlen as a loop condition

for (j = 0; j &lt; strlen(vow); j++)


Unless your compiler knows to optimize this out, strlen might be called every iteration in this code. To avoid this, put the length in its own variable.



Better Variable Names

Variable names such as i and c should only be reserved for loop indices. Use better variable names that clarify your intent.



fflush(stdin)

fflush(stdin)


https://stackoverflow.com/a/18170435/6525260. Don't play with undefined behavior.



getchar

In C++, a better way to wait for a character is:

std::cin.ignore(std::numeric_limits&lt;std::streamsize&gt;::max(), '\n');