Original Post
hi. i''m quite new here. enjoy reading all the posts but i havent really learnt anything because it''s a bit too complex for me... i''ve only been programming for 2 weeks( or 2 2hour lecture), but am enjoying it. i have to do it for uni cs course you see...
i have a bit of a problem with this code. the aim of the exercise is to find the prcentage of ''e'' characters in the whole sentance(not including the spaces). i can compile it and get it to run, but only if i declare one of the int(either non or e) as a float. it does not matter which i make a float, either one will do.(which is a bit strange). in this code, i have put both of them as a float:
#includeany help would be appreciated greatly...void main (void) { //int non, e; this line does not work??? had to put both as float... float total, e, non; char letter; e=0; non=0; cout << "please type in a sentance followed by a full stop" << endl; do { cin >> letter; if (letter==''e'' || letter==''E'') e++; else non++; } while (letter != ''.''); //cout << e << non << endl; just part of a testing line to check for errors total = 100 * (e / (e+non)); cout << total << "%"; }

