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;
}

Edited 6 Years Ago by Nick Evan: Added code-tags

I'm confused too.
There is no formatting making the code difficult to read.
There is no description of what you are having problems with.
There is no information about what is confusing.

Therefore, I have little to offer.

Nice outline of what you want your program to do; copied from your school assignment?
Don't you think it is a good idea to tell us what you've tried, what you suppose could be wrong and other information like that? Not to talk about those subjects of common sense actually are rules of this forum.

i already put my code , actually my code didnt work , therefore i need from u to help me to repair it to work , i already tried many time to work on it.
my code is beneath my question immediate, so you can look to it

i already put my code , actually my code didnt work , therefore i need from u to help me to repair it to work , i already tried many time to work on it.
my code is beneath my question immediate, so you can look to it

We answered you. We said:

There is no formatting making the code difficult to read.
There is no description of what you are having problems with.
There is no information about what is confusing.

This means that even though you posted code it is unreadable.
You didn't explain what you are having problems with

Don't you think it is a good idea to tell us what you've tried, what you suppose could be wrong and other information like that?

Repeats my complaint that you didn't explain what you are having problems with.

Therefore, we already answered you. Fix your question...

Edited 6 Years Ago by WaltP: n/a

i understand what you mean ... my problem already in this code so for this reason i mentioned the text problem then i set the code of that question , and that code have errors i actually dont know how to solve these errors , so what i ask is read my question text then my code ,,to help me solve my problem,,,,, here the text then the code i had been written ...


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

the code: -


#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[j];
}
for(i=0;i<6;i++)
{
length(x);}
sortalphabetical(x);
sortlength(x);
}
int length(char x[][80])
{
int sum=0; float avg;int f;
for (int i=0;x;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[j],t);
if (x>0){
t=x[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[80]);
if(max<l)
{
k=x[80];
x[80]=x[i+1][80];
x[i+1][80]=k;
}
cout<<x;
}

i understand what you mean ...

You obviously do not understand..

my problem already in this code

Yes, your problem is in the code. We do understand that.

so for this reason i mentioned the text problem then i set the code of that question ,

You mentioned, but did not explain the problem you are having. All you said is that there is a problem. Without knowing what the problem is, we cannot find a solution.

and that code have errors

Such as? Again, what errors do you have? Tell us!!!

i actually dont know how to solve these errors ,

Without knowing what the errors are, neither do we.

so what i ask is read my question text then my code ,,

We did. You explained nothing.

to help me solve my problem,,,,,

Tell us what the problem actually is.

here the text then the code i had been written ...

Without knowing what we are looking for, why bother reposting the code?

Give us DETAILS.

And use CODE Tags!

He said it!
And please in your next post, could you do your even better at making some more readable text? Because oh gosh you don't have to tell us English isn't your first language, but you should know some general grammar! :)
Good luck to you.

english not my tongue language i dont care if i have a little problem in it dear.... ok my problem i have problem of copying arrays to arrays ,,, and have problem to send pointers to functions and arrays either

This article has been dead for over six months. Start a new discussion instead.