C Program to find divisors of a given Integer

Sorry for not bringing enough contents in this summer. Well, I was busy.

                                                         Image Source


Today we will learn a C program which can calculate the divisors of a given number. It is easy. You can see the Source Code below...

 //Program for finding integer divisors of an number
#include<stdio.h>
void main()
{
    int num,div,ans;
    printf("Enter the number\n");
    scanf("%d",&num);
    for(div=2;div<=num;div++)
        if(num%div==0)
        printf("The divisor is %d\n",div);
}

A view on the sample output of the program....
 

That's enough for today, Bye. I will return soon with another post. stay tune.



Comments

Popular posts from this blog

How to calculate age using C program

How to install Windows 10 with USB Drive?

Restart Windows Explorer manually after Explorer crashes