bsc

Comprehensive codebase and cou...
Log | Files | Refs | Activity | README | LICENSE

root / semester_1 / tuition-c / APC-PRAC-040.c

APC-PRAC-040.c (771B)


      1 /*
      2 Write a C program to count how many numbers between 100 and 999 have all distinct digits (e.g., 123, 709, 981).
      3 */
      4 /* Author: Amit Dutta, Date: 21-11-2025 */
      5 
      6 // This code has not been compiled.
      7 // If you find any issues, please create a new issue on GitHub regarding them.
      8 // Go to this link to create a new issue: https://github.com/notamitgamer/bsc/issues
      9 
     10 #include <stdio.h>
     11 
     12 int main()
     13 {
     14     int i, count = 0, n1, n2, n3;
     15     printf("Distinct numbers between 100 and 999: ");
     16     for (i = 100; i <= 999; i++)
     17     {
     18         n1 = i / 100;
     19         n2 = (i % 100) / 10;
     20         n3 = i % 10;
     21         if (n1 != n2 && n2 != n3 && n1 != n3)
     22         {
     23             printf("%d  ", i);
     24             count++;
     25         }
     26     }
     27     printf("\nCount: %d\n", count);
     28     return 0;
     29 }
© notamitgamer • Site Built: 2026-09-05 01:53:16 UTC • git-mirror commit: c170d72 [view raw info]
Originally created with stagit • modified by notamitgamer
Forked from github.com/notamitgamer/git-mirror