Friday, 19 September 2014

WAP to check whether given two no. are amicable or not.

#include<conio.h>
#include<stdio.h>
void main()
{
clrscr();
int a,b,x,k;
k=0;
x=0;
printf("Enter the first no. for Amplicable or not : ");
scanf("%d",&a);
printf("\nEnter the second no.");
scanf("%d",&b);
for(int i=1;i<=a/2;i++)
{
if(a%i==0)
{
k+=i;
}
}
for(int j=1;j<=b/2;j++)
{
if(b%j ==0)
{
x+=j;
}
}
if(k==b && x==a)
{
printf("\n (%d,%d) is an Amplicable no.",a,b);
}
else
{
printf("\n (%d,%d) is an not Amplicable no.",a,b);
}
getch();
}

No comments:

Post a Comment

Please write your doubts