Use app×
QUIZARD
QUIZARD
JEE MAIN 2026 Crash Course
NEET 2026 Crash Course
CLASS 12 FOUNDATION COURSE
CLASS 10 FOUNDATION COURSE
CLASS 9 FOUNDATION COURSE
CLASS 8 FOUNDATION COURSE
0 votes
1.1k views
in Computer by (69.2k points)

Write a C program to test whether a given pair of numbers are amicable numbers. (Amicable number are pairs of numbers each of whose divisors add to the other number)

1 Answer

+1 vote
by (70.0k points)
selected by
 
Best answer

A C program to test whether a given pair of numbers is amicable numbers is as

follows:

#include<stdio.h>

#include<conio.h>

#include<math.h>

void main()

{

int i,j,n,sum_i=0,sum_j=0;

clrscr();

printf("enter any two numbers >");

scanf("%d%d",&i,&j);

 for(n=1;n<i;n++)

 {

 if (i%n==0)

 sum_i+=n;

 }

 for (n=1;n<j;n++)

 { if (j%n==0)

sum_j+=n;

}

if ((sum_j==i) && (sum_i==j))

printf ("\nAmicable");

else

printf ("\nNot Amicable");

getch();

}  

Welcome to Sarthaks eConnect: A unique platform where students can interact with teachers/experts/students to get solutions to their queries. Students (upto class 10+2) preparing for All Government Exams, CBSE Board Exam, ICSE Board Exam, State Board Exam, JEE (Mains+Advance) and NEET can ask questions from any subject and get quick answers by subject teachers/ experts/mentors/students.

Categories

...