i need a program that reads a paragraph of 6 lines of text. The user can enter extra spaces between words. The length of each line does not exceed 80 characters. The program should output the following:
1. The input paragraph without extra spaces between words
2. Average word length in the paragraph
3. The list of words in the paragraph sorted in alphabetical order
4. The 6 lines in the paragraph sorted in descending order of their length
i tried it but i feel it's confused to me,,, unclear .. so for this reason i put the question to help me to write it
#include<iostream.h>
void main()
{
char x[6][80];
cout<<"plze write your paragraph";
for(int i=0;i<6;i++)
for(int j=0;j<80;j++)
{
cin>>x[i][j];
}
for(i=0;i<6;i++)
{
length(x[i]);}
sortalphabetical(x);
sortlength(x);
}
int length(char x[][80])
{
int sum=0; float avg;int f;
for (int i=0;x[i];i++)
{sum+=i;
}
f=i;
avg=sum/6;
return f;
}
void sortalphabetical(char x[6][80])
{
char t[10][80]=x[0][0];
for(int i=0;i<6;i++)
for(int j=0;j<80;j++)
{
int x=strcmp(x[i][j],t);
if (x>0){
t=x[i][j];
}
}
cout<<x;
}
void sortlength(char x[6][80])
{
int max=length(x[0][80]);
int l; char k[10][80];;
for(int i=0;i<6;i++)
l=length(x[i][80]);
if(max<l)
{
k=x[i][80];
x[i][80]=x[i+1][80];
x[i+1][80]=k;
}
cout<<x;
}