pc-ip-06.c ​
Metadata ​
- Author — Amit Dutta (amitdutta4255@gmail.com)
- Last updated — 05 Jan 2026
- License — MIT
Problem Statement ​
Problem Statement
Question 6: Write a program using a function to compute and display all factors of a given number.
Source Code ​
Printing the code
To print this file, open it on GitHub and click Raw before printing, or use the Download Raw button above and print directly from that page.
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