-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexp-6-22.c
More file actions
42 lines (36 loc) · 742 Bytes
/
exp-6-22.c
File metadata and controls
42 lines (36 loc) · 742 Bytes
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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
/*************************************************************************
> File Name: exp-6-22.c
> Author: xiaoxiaoh
> Mail: xiaoxxhao@gmail.com
> Created Time: Mon Jul 10 14:58:27 2017
************************************************************************/
/*
* Write a C program to enter any number and print all factors of the number.
*
* Example
*
* Input
* Input number:
*
* Output
* Factors of 12: 1, 2, 3, 4, 6, 12
*
*/
#include <stdio.h>
int main()
{
int num, i, factor;
// Read a number from user
printf("Enter a number: ");
scanf("%d", &num);
printf("All factors of %d is:", num);
for(i=1; i<=num; i++)
{
if((num%i) == 0)
{
printf(" %d", i);
}
}
printf("\n");
return 0;
}