#include<iostream.h>
#include<conio.h>
void main()
{
clrscr();
long int n,i;
cout<<"\n Enter a number : ";
cin>>n;
cout<<"\n\t Divisors of "<<n<<" are : ";
for(i=1;i<=n;++i)
{
if(n%i==0)
cout<<" "<<i;
}
getch();
}
Output

#include<conio.h>
void main()
{
clrscr();
long int n,i;
cout<<"\n Enter a number : ";
cin>>n;
cout<<"\n\t Divisors of "<<n<<" are : ";
for(i=1;i<=n;++i)
{
if(n%i==0)
cout<<" "<<i;
}
getch();
}
Output
No comments:
Post a Comment