Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<stdio.h>
- #include<math.h>
- /*When declaring function, use the data type you want the output
- in throughout the entire function build*/
- int converter(int num, int base);
- int counter(int n);
- main()
- {
- int n, base, conv;
- scanf("%d %d", &n, &base);
- conv=converter(n,base);
- //printf("%d\n", conv);
- printf("%d", counter(conv));
- }
- int converter(int num, int base)
- {
- int rim, converted, i=0;
- while(num!=0)
- {
- rim=num%base;
- num=num/base;
- converted=rim+rim*pow(10,i);
- i++;
- }
- return converted;
- }
- int counter(int n)
- {
- int cnt=0;
- while(n!=0)
- {
- n=n/10;
- cnt++;
- }
- return cnt;
- }
Advertisement
Add Comment
Please, Sign In to add comment