#include <stdio.h>
void binary(int d);
void main(){
int d1,d2,d3,d4;
d1=d2=d3=d4=0;
printf("input decimal ip address:\n");
scanf("%d.%d.%d.%d",&d1,&d2,&d3,&d4);
printf("%3d.%3d.%3d.%3d\n",d1,d2,d3,d4);
printf("binary ip address:\n");
binary(d1);
binary(d2);
binary(d3);
binary(d4);
}
void binary(int d){
int i=0,j,n,b[9]={0};
while(d>0){
n=d%2;
d=d/2;
b[i++]=n;
}
for(j=7;j>=0;j--)
printf("%d",b[j]);
printf(" ");
}