bsc

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

root / semester_1 / practice-c / pc-ip-06.c

pc-ip-06.c (466B)


      1 /*
      2  * Question 6:
      3  * Write a program using a function to compute and display all factors of a given number.
      4  */
      5 
      6 #include <stdio.h>
      7 
      8 void printFactors(int);
      9 
     10 int main()
     11 {
     12     int n;
     13     printf("Enter the number: ");
     14     scanf("%d", &n);
     15     printFactors(n);
     16     return 0;
     17 }
     18 
     19 void printFactors(int n)
     20 {
     21     int i;
     22     printf("\nFactors of %d:", n);
     23     for (i = 1; i <= n; i++)
     24     {
     25         if (n % i == 0)
     26         {
     27             printf("  %d", i);
     28         }
     29     }
     30 }
© 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