pc-ip-06.c
Problem Statement
pc-ip-06.c
Question 6: Write a program using a function to compute and display all factors of a given number.
Source Code
c
#include <stdio.h>
void printFactors(int);
int main()
{
int n;
printf("Enter the number: ");
scanf("%d", &n);
printFactors(n);
return 0;
}
void printFactors(int n)
{
int i;
printf("\nFactors of %d:", n);
for (i = 1; i <= n; i++)
{
if (n % i == 0)
{
printf(" %d", i);
}
}
}1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
● Author - Amit Dutta · Updated - 05 Jan 2026