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

Download Application: Learn C Programming with Live Compiler

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

Flowchart : Program to find factor of a number

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
guest
0 Comments
Inline Feedbacks
View all comments

Join Our Newsletter Now

Get the latest tutorials, examples and projects updates.

Ads Block Detector Powered by codehelppro.com

Ads Blocker Detected!!!

We have detected that you are using extensions to block ads. Please support us by disabling these ads blocker.

Disable Ad Block

Want Same System