Created
March 30, 2015 17:36
-
-
Save drifterz28/97ec4d50773015bf14ce to your computer and use it in GitHub Desktop.
spliting numbers in c++
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Example program | |
#include <iostream> | |
#include <cmath> | |
using namespace std; | |
int main() | |
{ | |
// declaring variables: | |
int a, remainder; | |
int result, result2, result3; | |
// process: | |
a = 357; | |
result = floor(a / 100); | |
remainder = a % 100; | |
result2 = floor(remainder / 10); | |
remainder = a % 10; | |
result3 = remainder % 10; | |
// print out the result: | |
cout << result; | |
cout << result2; | |
cout << result3; | |
// terminate the program: | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment