Click here to Skip to main content
15,887,812 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
Hi coders!
i want assistance in one tiny problem. want to split one integer number into multiple parts e.g. Int Number = 645.I want to divide it into two parts p1= 600 and p2 = 45. OR
Number= 3658.
p1=3000;
p2=600;
p3= 58;
how i can get this in C++/QT.
Posted

1 solution

The modulus operator (%) is your friend. You know, for instance:
C++
int i = 645;
int a = i % 100; // a is 45
int b = i - a; // b is 600
 
Share this answer
 
Comments
XamBEE 23-Nov-15 4:15am    
Thanks
CPallini 23-Nov-15 4:57am    
You are welcome.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900