APC-PRAC-038.c
Metadata
- Author — Amit Dutta (amitdutta4255@gmail.com)
- Last updated — 12 Dec 2025
- License — MIT
Problem Statement
Problem Statement
Print all combinations of two two-digit numbers such that the sum of digits of both numbers is equal. Example: 23 and 41 → (2+3) = 5, (4+1) = 5.
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()
{
printf("Combinations of two two-digit numbers such that the sum of digits of both numbers is equal: ");
int i, j, sum1, sum2, count = 0;
for (i = 10; i <= 99; i++)
{
sum1 = (i % 10) + (i / 10);
for (j = i + 1; j <= 99; j++)
{
sum2 = (j % 10) + (j / 10);
if (sum1 == sum2)
{
printf("(%d, %d) ", i, j);
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
21
22
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22