hay guys i have hw assignment to make a programe which will take a number and print it line wise at screen ..for example if i give 3121 then it will print
3
1
2
1
help me soooooooooon
thats right ashley. But what if the user enters a number like 1234, technicly that will all be read into the input and when you cout the input it will be on one line. I think the best way would be to use a string input like this.
string input;
cout << "Enter a number....any size: ";
cin >> input;
for(int i = 0; i < input.length(); i++)
cout << input.at(i) << endl;
this is probably the easiest way, the other way would be to use mod statements, and the program wouldnt be that flexible. for instance if you were to enter this for a number
1237826783553272527362826422826227 and you had the data type to anything other than a string, you would not print out the correct stuff. that is a huge number, so i think string is best if you want a program that will work with just about any size number.
lol, thats cool warnis. at least we think the same. I know it works with a string perfectly. It just doesnt seem right at first glance.... string and a number??? But yea, glad you think the same