Hello, I have a problem solving a similar problem..It is about IPv4.
I have to create a program in C that we will give as an input the IP address and the subnet mask in dotted decimal form and it will provide in the output
Here is the code I have written until now. Any help would be higly appreciated.

#include <stdio.h>
#include <stdlib.h>

int i=0, j, a, b, c;
int decimal;
int g[]={0}, k[]={0};

//decimal to binary
int dectobin(a) {
i=0;
do {
decimal=a%2;
g[i]=decimal;
i++;
a=a/2;
}while (a>0);

for (j=i-1;j>=0;j--) {
printf("%d",g[j]);
}
}

int dectohex(b) {
i=0;
do {
decimal=b%16;
k[i]=decimal;
i++;
b=b/16;
}while (b>0);

for (j=i-1;j>=0;j--) {
printf("%X",k[j]);
}
}

//binary to decimal
int bintodec(char *bin) {
i=0;
// don't know how to do it!
}

int main()
{

int x,y,z,w; // for the IP
int l,m,n,p; // for the subnet mask

printf("seperated by a space: ");
scanf("%d%d%d%d",&x,&y,&z,&w);

while ( (x>255)||(x<0)||(y>255)||(y<0)||(z>255)||(z<0)||(w >255)||(w<0) ) {
printf("IP Address not valid! Re-enter:\n ");
scanf("%d %d %d %d",&x,&y,&z,&w);
}

printf("\n\n");

scanf("%d %d %d %d",&l,&m,&n,&p);
// IP class A with the first octet of the subnet 255.xxx.xxx.xxx
if ( (x>=0)&&(x<=127) ) {
while ( (l!=255) ) {

scanf("%d %d %d %d",&l,&m,&n,&p);
}

// dotted decimal
//binary
printf("\n");

// in dotted decimal

// in binary

// IP class B
else if ( (x<=191) ) {

// IP class C
else if (x<=223) {

// IP class D
else if(x<=239) {
{
printf("This class of IPs is reserved for multicasting purposes.\n");
}

// IP class D
else {