#include <stdio.h> int main() { int sum; printf("Enter the sum of digits: "); scanf("%d", &sum); printf("Three-digit numbers with given sum of digits:\n"); for (int i = 100; i < 1000; i++) { int num = i; int digit1 = num / 100; num %= 100; int digit2 = num / 10; int digit3 = num % 10; if (digit1 + digit2 + digit3 == sum) { printf("%d\n", i); } } return 0; }
int main() {
int sum;
printf("Enter the sum of digits: ");
scanf("%d", &sum);
printf("Three-digit numbers with given sum of digits:\n");
for (int i = 100; i < 1000; i++) {
int num = i;
int digit1 = num / 100;
num %= 100;
int digit2 = num / 10;
int digit3 = num % 10;
if (digit1 + digit2 + digit3 == sum) {
printf("%d\n", i);
}
}
return 0;
}