c program to check two numbers are amicable or not

list of programs below: c program to check two numbers are amicable or not using functions, c program to check two numbers are amicable or not without functions

Two numbers are amicable if the sum of the proper divisors of each is equal to the other number.

Example of amicable pair numbers are: 220 and 284

The divisors of 220 are 1, 2, 4, 5, 10, 11, 20, 22, 44, 55 and 110, of whose sum is 284; and the proper divisors of 284 are 1, 2, 4, 71 and 142, of whose sum is 220. so 220 & 284 amicable pair numbers

other amicable pair numbers are:
1184, 1210
2620, 2924
5020, 5564
6232, 6368

Note: generally amicable pair numbers are both even or both are odd.

Amicable pair numbers program logic:
For all numbers below 1000 find factors for each n and sum them ( m ) and for each sum ( m ) again find sum of factors and check if equal to n, if so, both m & n are amicable pair numbers.

c program to check two numbers are amicable or not using functions without
c program to check two numbers are amicable or not using functions without

write a C program to check two numbers are amicable pairs or not using functions

write a C program to check two numbers are amicable pairs or not

#include<stdio.h>
#include<conio.h>
int main()
{
int firstnumber,secondnumber;
printf(” OUTPUT: C program to find two numbers are amicable or not using functions \n \n”);
printf(“Enter first number : “);
scanf(“\n %d \n”,&firstnumber);
printf(“Enter second number : “);
scanf(“\n %d \n”,&secondnumber);
find_amicable_or_Not(int firstnumber, int secondnumber);
}

// function for amicable pairs
void find_amicable_or_Not(int n, int m)
{
int sum1=0,sum2=0,i;
for(i=1; i<=n/2 ; i++)
{
if(n%i==0)
sum1=sum1+i;
}
for(i=1; i<m/2 ; i++)
{
if(m%i==0)
sum2=sum2+i;
}
if(n==sum2 && m==sum1)
printf(“\n Given numbers are Amicable pairs”);
else
printf(“\n Given numbers are Not Amicable pairs”);
getch();
}

output :OUTPUT: C program to find two numbers are amicable or not using functions

OUTPUT: C program to find two numbers are amicable or not using functions

write a C program to check two numbers are amicable or not  without functions

write a C program to check two numbers are amicable or not  without functions

#include<stdio.h>
#include<conio.h>
int main()
{
int n,m,sum1=0,sum2=0,i;
printf(“OUTPUT: C program to find two numbers are amicable or not without functions \n \n”);
printf(“Enter first number : “);
scanf(“\n%d\n”,&n);
printf(“Enter second number : “);
scanf(“\n%d\n”,&m);
for(i=1; i<=n/2 ; i++)
{
if(n%i==0)
sum1=sum1+i;
}
for(i=1; i<m/2 ; i++)
{
if(m%i==0)
sum2=sum2+i;
}
if(n==sum2 && m==sum1)
printf(“\n Given numbers are Amicable pairs”);
else
printf(“\n Given numbers are Not Amicable pairs”);
getch();
}
output:

OUTPUT: C program to find two numbers are amicable or not without functions

OUTPUT: C program to find two numbers are amicable or not without functions

Other programs:

Static variable scope
Register variable scope
External variable scope
Automatic variable scope
amicable number
Prime number
Perfect number
Palindrome number
Strong number
Find Factorial 
Biggest Number
Average of n numbers
decimal number to octal
convert decimal number to hexadecimal
decimal number to binary
simple interest
compound interest
Add sparce matrices
Add matrices
 file copying
Palindrome string
Reverse string
String length
Replace characters in string
substring or not using arrays
First occurrence of character in string
Last occurrence of character in string
Convert to uppercase
Convert to lowercase
Concatenate strings 
Compare strings
Generate Employee payslips
Count students scoring marks>50%
convert weight into grams

 

Leave a Reply

Your email address will not be published. Required fields are marked *