CODE
#include <iostream>
using namespace::std;
void main(){
char ch;
int a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,zero,one,two,three, four , five,six , seven, eight, nine;
while ( cin.get(ch) )
if ( ch == 'a'|| 'A' ) ++a;
if ( ch == 'b'|| 'B' ) ++b;
if ( ch == 'c'|| 'C' ) ++c;
if ( ch == 'd'|| 'D' ) ++d;
if ( ch == 'e'|| 'E' ) ++e;
if ( ch == 'f'|| 'F' ) ++f;
if ( ch == 'g'|| 'G' ) ++g;
if ( ch == 'h'|| 'H' ) ++h;
if ( ch == 'i'|| 'I' ) ++i;
if ( ch == 'j'|| 'J' ) ++j;
if ( ch == 'k'|| 'K' ) ++k;
if ( ch == 'l'|| 'L' ) ++l;
if ( ch == 'm'|| 'M' ) ++m;
if ( ch == 'n'|| 'N' ) ++n;
if ( ch == 'o'|| 'O' ) ++o;
if ( ch == 'p'|| 'P' ) ++p;
if ( ch == 'q'|| 'Q' ) ++q;
if ( ch == 'r'|| 'R' ) ++r;
if ( ch == 's'|| 'S' ) ++s;
if ( ch == 't'|| 'T' ) ++t;
if ( ch == 'u'|| 'U' ) ++u;
if ( ch == 'v'|| 'V' ) ++v;
if ( ch == 'w'|| 'W' ) ++w;
if ( ch == 'x'|| 'X' ) ++x;
if ( ch == 'y'|| 'Y' ) ++y;
if ( ch == 'z'|| 'Z' ) ++z;
if ( ch == '0') ++zero;
if ( ch == '1') ++one;
if ( ch == '2') ++two;
if ( ch == '3') ++three;
if ( ch == '4') ++four;
if ( ch == '5') ++five;
if ( ch == '6') ++six;
if ( ch == '7') ++seven;
if ( ch == '8') ++eight;
if ( ch == '9') ++nine;
cout<<a<<"a's were found. \n";
}
1.what i trying to do is to calculate elements from 32 to 126 in ASCII. i need to record down how frequent each element type by user. i know this not the right way to write it, but this is first idea since i look the question....
2.Y my "cout<<a<<"a's were found. \n";" not working?But when i put "{}" within the "while" and "if", then the answer come out but repeating the answer.
3.After done the coding above, i was thinking can we directly compare the input with the ASCII?