pc-ip-06.c (602B)
1 /* 2 * Author: Amit Dutta (amitdutta4255@gmail.com) | Date: 05 Jan 2026 3 * Repo: https://github.com/notamitgamer/bsc 4 * License: MIT 5 */ 6 7 /* 8 * Question 6: 9 * Write a program using a function to compute and display all factors of a given number. 10 */ 11 12 #include <stdio.h> 13 14 void printFactors(int); 15 16 int main() 17 { 18 int n; 19 printf("Enter the number: "); 20 scanf("%d", &n); 21 printFactors(n); 22 return 0; 23 } 24 25 void printFactors(int n) 26 { 27 int i; 28 printf("\nFactors of %d:", n); 29 for (i = 1; i <= n; i++) 30 { 31 if (n % i == 0) 32 { 33 printf(" %d", i); 34 } 35 } 36 }