fork download
  1. #include<iostream>
  2. using namespace std;
  3. int main() {
  4. int first3, middle3, last3;
  5. int original, temp, first, second,third, fourth, first1, second1, third1, fourth1;
  6. cout<<"enter a 7-9 digit number"<<endl;
  7. cin>>original;
  8. temp=original/1000;
  9. cout <<"temp= "<< temp<< endl;
  10. last3=original%1000;
  11. cout << "last3= "<< last3 << endl;
  12. first=last3/10;
  13. cout <<"first= "<< first << endl;
  14. second=last3%10;
  15. cout <<"second= " <<second << endl;
  16. third=first/10;
  17. cout <<"third= "<< third << endl;
  18. fourth=first%10;
  19. cout <<"fourth= "<< fourth << endl;
  20. first3=temp/1000;
  21. cout <<"first3= "<< first3 << endl;
  22. middle3=temp%1000;
  23. cout <<"middle3= "<< middle3 << endl;
  24. first1=middle3/10;
  25. cout <<"first1= "<< first1 << endl;
  26. second1=middle3%10;
  27. cout <<"second1= "<< second1 << endl;
  28. third1=first1/10;
  29. cout <<"third1= "<< third1 << endl;
  30. fourth1=first1%10;
  31. cout <<"fourth1= "<< fourth1 << endl;
  32. cout<<"the number with a comma is "<<endl;
  33. cout<<first3<<","<<first1<<second1<<third1<<","<<first<<second<<third<<endl;
  34. cout<<first3<< ","<<middle3<<","<< last3<< endl;
  35. return 0;
  36. }
Success #stdin #stdout 0.02s 2684KB
stdin
1234567
stdout
enter a 7-9 digit number
temp= 1234
last3= 567
first= 56
second= 7
third= 5
fourth= 6
first3= 1
middle3= 234
first1= 23
second1= 4
third1= 2
fourth1= 3
the number with a comma is 
1,2342,5675
1,234,567