APC-PRAC-040.c ​
Metadata ​
- Author — Amit Dutta (amitdutta4255@gmail.com)
- Last updated — 12 Dec 2025
- License — MIT
Problem Statement ​
Problem Statement
Write a C program to count how many numbers between 100 and 999 have all distinct digits (e.g., 123, 709, 981).
Source Code ​
Printing the code
To print this file, open it on GitHub and click Raw before printing, or use the Download Raw button above and print directly from that page.
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