### Split an integer

To split an integer, we first need to know the count of digits in the integer. I've wrote an article on how to find it, read it here.

Below is the solution to split an integer into two parts:

#include <stdio.h> #include<math.h> int main(void) { int n, divisor, len; printf("Enter a no.: "); scanf("%d", &n); if(n!=0){ len=floor(log10(n))+1; divisor=pow(10, len/2); printf("1st part: %d\n2nd part: %d", n/divisor, n%divisor); } return 0; }

Happy programming!

If you've found any errors or want to give a feedback then comment below.

## Comments

## Post a Comment