#include <stdio.h>
int main() {
int A[10];
int B[10];
int count = 0;
for (int i = 0; i < 10; i++) {
scanf("%d", &A[i]);
}
for (int i = 0; i < 10; i++) {
int tens = (A[i] / 10) % 10;
if (tens == 0) {
B[count] = A[i];
count++;
}
}
for (int i = 0; i < count; i++) {
printf("%d ", B[i]);
}
return 0;
}
This program reads 10 integers into array A, then copies to array B only those numbers whose tens digit is 0, and finally prints the contents of B.
- The condition `tens == 0` checks if the tens digit is zero, but this will also include numbers with fewer than two digits (like 5 or 0) because integer division truncates. Consider what happens for numbers like 5 or 100 — do they really have a tens digit of 0 in the way you intend?
- The variable `tens` is computed as `(A[i] / 10) % 10`. For a number like 105, this gives 0, but the tens digit is actually 0. For a number like 5, `5/10` is 0, so `tens` becomes 0 as well. Think about whether you want to include single-digit numbers or numbers like 100 in the result.