Comma formatting
Mar 19, 2013 at 10:14pm UTC
I'm having little trouble getting the numbers a user enters to be formatted appropriately. I can only use modolus and division for this im getting the first three number to show but cant seem to get the next numbers and also. I am having trouble on inputting the comma.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40
#include<iostream>
using namespace std;
int main ( int argc, char * argv[] )
{
unsigned long long userInput;
int answer;
cout << "Enter a long long number: " << endl;
cin >> userInput;
answer = userInput /= 1000;
answer %= 1000;
cout << "Number: " << userInput << "," << answer << endl;
system("pause" );
return 0;
}
Mar 19, 2013 at 10:18pm UTC
What is the problem with the comma?
Are you asking about the program logic, or simply about the output statement?
Mar 19, 2013 at 10:32pm UTC
At this point both, some guidance on how to approach it would be helpful.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34
#include<iostream>
using namespace std;
int main ( int argc, char * argv[] )
{
unsigned long long userInput;
int fthreeDigit;
cout << "Enter a long long number: " << endl;
cin >> userInput;
fthreeDigit = ( userInput / 1000 );
userInput %= 1000;
cout << "Your Number: " << fthreeDigit << "," << userInput << endl;
system("pause" );
return 0;
}
Last edited on Mar 20, 2013 at 12:19am UTC
Topic archived. No new replies allowed.