int
main()
02 | { |
03 | int num; |
04 | cout << "Please enter an integer between 1,000 and 1,000,000 without commas: " ; |
05 | cin >> num; |
06 |
07 | int modulus = num%1000; |
08 | if (num >= 1000 && num <1000000) { |
09 | cout << (num-modulus)/1000 << ',' ; |
10 | if (modulus < 100) cout << '0' ; |
11 | if (modulus < 10) cout << '0' ; |
12 | cout << modulus << endl ; |
13 | } |
14 | else cout << "your number is not valid" << endl ; |
15 |
16 | return 0; |
17 | } |
No comments:
Post a Comment