English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

vOID MAIN ()
{
int i
char str[50];


cout<<"enter the string or name ";
cin >>str;

cout <<"MENU \n";
cout<<"1: counting of words\n";
cout<<"2: sorting of words\n";
cout<<"3: reversing of words\n";
cout<<"4: exit\n";

cout<<" enter your choice";
cin>>x;


switch(x)
{

case 1:
cout>>"menu chosen to count the wrds\n";
count=countw(str);
cout>>"no of words=">>count;
break;

case 2:
cout>>"menu chosen to sort the wrds\n";
cout>>"string before sorting \t">>str;
sortw(str);
cout>>"string after sorting \t">>str;
break;

case 3:
cout>>"menu chosen to reserve the wrds\n";
cout>>"string before reversing \t">>str;
reversew(str);
cout>>"string after sorting \t">>str;
break;

case 4:
break;
}//end of swtich
}//end of main()


int count(char str)
{


int i,j,len,w=0;

len=strlen(str);
for (i=0;i<=len;i++)
{
if(str[i]==' ' || str[i+1]==' ' || str[i+1]=='\t')// CHK STATMNT FOR WHITE CONTINUES SPACES
w++;
else
continue;
}
w++;
return(w);
}//end of fun count


void sortw(char str)
{

int i,j=0,m,k;
char x[15];
static x1=0;

for (i=0;i<=strlen(str);i++)
{


if(str[i]==' ' || str[i+1]==' ' || str[i+1]=='\t')// CHK STATMNT FOR WHITE CONTINUES SPACES
{
k=i;
for (m=x1;m {
x[j++]=str[m]; // READS INDIVIDUAL WORDS INTO A TEMP ARRAY THAT PERFORMS INTERMEDIATE JOBS

}

x[m]='\0';
int temp ;
for( z=0; z {
for(j=0;j {
if (x[j]>x[i])
{
temp=x[i]; // THIS PERFORMS SWAPIN OF VALUES THRU BUBBLE SORT
x[i]=x[j];
x[j]=temp;
}
}
}
else
continue;
}//end of outter for
//now the for loop is to make the changes to the string array str
for (m=x1;m {
str[m]=x[m];
}
x1=k+1;

cout<<"the sorted string is \n"< }//end of fun sortw



void revw(char str)
{
int i,j,x1=0,m;

for (i=0;i<=strlen(str);i++)
{


if(str[i]==' ' || str[i+1]==' ' || str[i+1]=='\t')// CHK STATMNT FOR WHITE CONTINUES SPACES
{
k=i;
for (m=x1;m {
x[j++]=str[m]; // READS INDIVIDUAL WORDS INTO A TEMP ARRAY THAT PERFORMS INTERMEDIATE JOBS

}

x[m]='\0';

//now the for loop is to make the changes to the string array str
for (m=x1,j=strlen(x);j>0;j--,m++)
{
str[m]=x[j];
}
x1=k+1;
}//end of outter if

}//end of for loop
cout <<"the reversed string is "<<'\t'< }//end of fun reverse

2006-10-23 23:57:42 · 2 answers · asked by ramesh d 2 in Computers & Internet Programming & Design

2 answers

too many errors to tell, besides the output would depend on the input, and what option was selected.

2006-10-24 02:08:02 · answer #1 · answered by justme 7 · 0 0

Too many errors, vOID MAIN is wrong: void main is correct.

Function : countw(str); NOT DEFINED

cout cannot be overloaded with '>>' operator the operator is '<<'
function : int count(char); cannot take char pointer or array as argument, a type mismatch error will result.

Check the '{' and '}'s, quite a mess you have there.


FIRST GET A TURBO C++ / BORLAND C++ IDE, then compile and learn.

2006-10-25 04:49:05 · answer #2 · answered by Rahul Ghose 4 · 0 0

fedest.com, questions and answers