APC-PRAC-040.c
Problem Statement
APC-PRAC-040.c
Write a C program to count how many numbers between 100 and 999 have all distinct digits (e.g., 123, 709, 981).
Source Code
c
#include <stdio.h>
int main()
{
int i, count = 0, n1, n2, n3;
printf("Distinct numbers between 100 and 999: ");
for (i = 100; i <= 999; i++)
{
n1 = i / 100;
n2 = (i % 100) / 10;
n3 = i % 10;
if (n1 != n2 && n2 != n3 && n1 != n3)
{
printf("%d ", i);
count++;
}
}
printf("\nCount: %d\n", count);
return 0;
}1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
● Author - Amit Dutta · Updated - 12 Dec 2025