can somebody give me the code for the program that "allows the user to enter a sentence" then the program will count and sort the characters input. I need this on 2 days so please, somebodyh help me, please.
JSH:Hi... Please note.... ---------- Code: /* Javad Sharyati */ #include<iostream.h> #include<conio.h> char str[100]; int leng=-1; //------------------- void get_str() { cout<<"\n\n Please Enter a Sentence \n ------ \n"; char ch=getch(); int i=0; while(ch != '\r' ) { int chr=(int) ch ; if( chr == 8 && i > 0 ) { str[i]='\0'; leng--; i--; } if((chr>=48 && chr<=57)||(chr>=65 && chr<=90)||(chr>=97 && chr<=122)||chr==32) { str[i]=ch; leng=i; i++; } } } //------------------------ void swap(int a,int b) { char temp; temp=str[a]; str[a]=str[b]; str[b]=temp; } //------------------------ void sort() { for(int i=0;i<leng;i++) { for(int j=i+1;j<=leng;j++) { if(str[i] < str[j]) swap(i,j); } } } //------------------ void out() { cout<<"\n-------------\n "; for(int i=0;i<=leng;i++) cout<<str[i]; } //------------------- void main() { get_str(); sort(); out(); } you can chang functions( sort , get_str , swap , out );