How to split an integer into two parts the last digit and the rest in C++

1 Answer

0 votes
#include <iostream>

int main() {
    int n = 89756;
 
    int part_a = n / 10;
    int part_b = n % 10;
 
    std::cout << part_a << " " << part_b;
}
 
 
 
 
/*
run:
 
8975 6
 
*/

 



answered Jun 15, 2022 by avibootz

Related questions

...