In addition to what Carlo has told you, do yourself a couple of favours:
1) Indent your code properly, and always use curly brackets, even if it's "only one statement". Particularly when you are just starting, this makes your code easier to read and modify.
Here is your (unmodified) code indented and bracketed:
int main(void)
{
int borrow, i, n, j, f;
int x[100]= {0}, y[100]= {0}, difference[100]= {0};
scanf("%d", &x[i]);
scanf("%d", &y[i]);
borrow = 0;
for (i == 0; n - 1; i++ )
{
if(y[i] <= x[i])
{
difference[i] = x[i]- y[i];
}
else if (i = n - 1)
{
borrow = 1;
x[i] = x[i] + 10;
difference[i] = x[i] - y[i];
}
else
{
j = i + 1;
}
}
while (x[j] == 0 && j < n)
{
j = j + 1;
j = j - 1;
}
while (j > i)
{
x[j] = x[j] + 10 - 1;
j = j - 1;
difference[i] = x[i] - y[i];
}
printf("%d",difference[i]);
return 0;
}
Can you see how much easier it is to tell where your
for
loop ends?
2) Stop using single character variable names: it's quick to type, but it makes it harder to read and understand. Using "descriptive" names that tell you what the variable is used for helps your code become self documenting, and with modern IDE's takes hardly any extra time to use! OK -
borrow
and
difference
are descriptively named, but what are
x
,
y
,
i
,
n
,
j
, and
f
for? You don't even use one of them!
3) Do you want to tell me what this code does?
while (x[j] == 0 && j < n)
{
j = j + 1;
j = j - 1;
}