#include<math.h>
int main()
{
printf("enter your ip addr part by part mean your ip addr is has 4 part \n enter 1st then press enter so on\n");
int e,c,l,z,t,x,v,b,a[4][8];
printf("enter 1st part\n");
scanf("%d",&z);
printf("enter 2nd part\n");
scanf("%d",&t);
printf("enter 3rd part\n");
scanf("%d",&x);
printf("enter last part\n");
scanf("%d",&v);
printf("\n so the %d.%d.%d.%d\n the binary of the number is\n",z,t,x,v);
printf("\n%d=",z);
for (c = 7; c >= 0; c--){
l = z >> c;
if (l & 1){
a[0][c]=1;
printf("1");
}
else{
a[0][c]=0;
printf("0");
}
}
printf("\n");
printf("\n%d=",t);
for (c = 7; c >= 0; c--){
l = t >> c;
if (l & 1){
a[1][c]=1;
printf("1");
}
else{
a[1][c]=0;
printf("0");
}
}
printf("\n");
printf("\n%d=",x);
for (c = 7; c >= 0; c--){
l = x >> c;
if (l & 1){
a[2][c]=1;
printf("1");
}
else{
a[2][c]=0;
printf("0");
}
}
printf("\n");
printf("\n%d=",v);
for (c = 7; c >= 0; c--){
l = v >> c;
if (l & 1){
a[3][c]=1;
printf("1");
}
else{
a[3][c]=0;
printf("0");
}
}
printf("\n");
printf("the array of ip addrres in binaary is\n");
for (c = 7; c >= 0; c--){
printf("%d",a[0][c]);
}
printf("\n");
for (c = 7; c >= 0; c--){
printf("%d",a[1][c]);
}
printf("\n");
for (c = 7; c >= 0; c--){
printf("%d",a[2][c]);
}
printf("\n");
for (c = 7; c >= 0; c--){
printf("%d",a[3][c]);
}
return 0;
}
No comments:
Post a Comment