Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<iostream>
- #include <stdio.h>
- #include<string>
- using namespace std;
- void main()
- {
- char names[10][30];
- cout<<"plz enter ten names each of names to most 30 charcter"<<endl;
- for(int i=0;i<10;i++)
- {
- cin>>names[i];
- }
- char appe[1000] ={};
- for(int i=0;i<10;i++)
- {
- strcat(appe,names[i]);
- strcat(appe," ");
- }
- cout<<appe<<endl;
- int sum=0;
- for(int i=0;i<10;i++)
- sum+=strlen(names[i]);
- cout<<"the averge length for these name is : "<<sum/10.0<<endl;
- cout << "the alphabetical sort of these name is : " ;
- char temp[30];
- int i,t;
- for( i=0;i<10;i++)
- {
- for( t=i+1;t<10;t++)
- if (strcmp(names[i],names[t])>0)
- {
- strcpy(temp,names[i]);
- strcpy(names[i],names[t]);
- strcpy(names[t],temp);}
- }
- cout<<"The alphabetical order of the words is :"<<endl;
- for(int i=0;i<10;i++)
- cout<<names[i]<<endl;
- //
- //
- for( i=0;i<10;i++)
- {
- for( t=i+1;t<10;t++)
- if (strlen(names[i])>strlen(names[t]))
- {
- strcpy(temp,names[i]);
- strcpy(names[i],names[t]);
- strcpy(names[t],temp);}
- }
- cout<<"The words order accodring to length is :"<<endl;
- for(int i=0;i<10;i++)
- cout<<names[i]<<endl;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement