Given two numbers. I want to compare the two numbers positional notations.
Say number 1 is: 25000 Say number 2 is: 25000
And the result is the mask. If each positions match, then the mask (in this case) is: 6
Say number 1 is: 00000 Say number 2 is: 22220
Then the mask is 1, because only the first bit matches.
My logic was, if the length of the two numbers aren't equal, then it prints that it isn't equal, and does nothing. But if they match, then I convert them to integers. And after that, I check with 2 for loops if their respective numbers are equal. If they are, then I add one to the maszk variable.
My code is wrong below (I have already entered the headers and declared the variables and the getline.) Can anyone help?
#include <stdio.h>
if( strlen(s) != strlen(s2) ) printf("The length doesn't match! \n");
else {
for(i=0; i<=20; i++)
{
for(j=0; j<=20; j++)
{
szam1[i] = atoi(s);
szam2[j] = atoi(s2);
}
if( szam1[i] == szam2[j] ) maszk++;
}
}
printf("The mask of the two numbers: %d", mask);
}