#include <stdlib.h>
#include <stdio.h>
#include <math.h>
#define size 10//how many bits to present the integer
void getBits(int,int[],int);
int main(void){
int bits [size]={0};//initial all bits to 0;
getBits(24,bits,8);//10進位24的8進位表示法
for(int i=size-1;i>=0;i--){
printf("%d",bits[i]);
}
return 0;
}
void getBits(int integer,int bits[],int b){
int q=integer;
int k=0;
while(q!=0){
bits[k]=q%b;//get the mod;
q=ceil(q/b);//Returns the smallest integer value greater than or equal to x.
k+=1;
}
}