Signup/Sign In
LAST UPDATED: DECEMBER 4, 2020

Program to find Divisor of a Number in C++

Following is the program to find divisor of a given number.

#include<iostream.h>
#include<conio.h>

int main()
{
    int i, n1;
    clrscr() ;
    cout<<"Enter the number to find it's divisors : " ;
    cin>>n1 ;
    cout<<"\nThe divisors are :\n") ;
    for(i = 1 ; i <= n1 ; i++)
        if(n1 % i == 0)
            cout<<"\t"<<i ;
    getch() ;
    return 0;
}


Enter the number to find it's divisors : 21
The divisors are :
1 3 7 21



About the author:
Nikita Pandey is a talented author and expert in programming languages such as C, C++, and Java. Her writing is informative, engaging, and offers practical insights and tips for programmers at all levels.