Courses

### Courses

Structure and Union

No Examples found for this topic - CodeHelpPro

Data Files

No Examples found for this topic - CodeHelpPro

# Program to find factor of a number

0 Suresh Chand June 2, 2021

In this example, We will learn a program to find factor of a number. You must have knowledge in following topics before looking this example

## Algorithm

This is the algorithm of this program

```Step 1: Start
Step 2: Initialize a variables num
Step 3: Take input from user and store in num
Step 4: Assign i = 1
Step 5: REPEAT this step until u <= num / 2
IF num % i == 0
Print i
Increase i by 1
Step 6: End```

## Flowchart

This is the flowchart of this program

## CODE: Program to find factor of a number

Now, We will see the code to find factor of a number

``````#include <stdio.h>

int main()
{

int num, i;

printf("Enter the number to find the factors of :  ");
scanf("%d", &num);

printf("\nFactors of %d are \n", num);

for (i = 1; i <= num / 2; i++)
{
if (num % i == 0)
printf("\t%d", i);
}

return 0;
}``````

The output of above program is

``````Enter the number to find the factors of :  12

Factors of 12 are
1       2       3       4       6``````
Subscribe
Notify of
Inline Feedbacks