Skip to content

p039.c

Problem Statement

Write a program to print all the factors of a postive integer

Metadata

Property Detail
Author Amit Dutta (amitdutta4255@gmail.com)
License MIT

Actions

Raw View on GitHub

💡 You can print or save this file by opening Raw and using your browser.

Source Code

#include <stdio.h>

int main()
{
    int num, i;
    printf("Enter a number : ");
    scanf("%d", &num);
    printf("\nFactors of %d : ", num);
    for (i = 1; i <= num / 2; i++)
    {
        if (num % i == 0)
        {
            printf("  %d", i);
        }
    }
    return 0;
}