I'm just testing what I've wrote so far to check if it's correct, but it's not...where did I go wrong?
Code:/* Purpose: This program accepts a number, up to 5-digits, and the prints it out in English. */ #include<iostream.h> int main() { //User's inputs, stored in char, so whitespace characters can be evaluated char char1; char char2; char char3; char char4; char char5; //variable that will count the digits the user will input, intialized to 0 int digits; digits=0; //Program Description and prompt to user cout<<"This program accepts a number, up to 5-digits and then prints it out\n" <<"in English. Please enter in a 5-digit or less number: "; //Getting user's data cin>>char1; cin.get(char2); cin.get(char3); cin.get(char4); cin.get(char5); if(char5==' ') digits++; if(char4==' ') digits++; if(char3==' ') digits++; if(char2==' ') digits++; if(char1==' ') digits++; //trying to get digits to print out, why doesn't it work? cout<<endl<<endl<<digits; return 0; }



LinkBack URL
About LinkBacks


