Showing posts with label how to check two numbers are amicable or not in c. Show all posts
Showing posts with label how to check two numbers are amicable or not in c. Show all posts

Thursday, 6 April 2017

C Program to Check Whether Two Numbers are Amicable or Not


Program :-

#include <sidio.h>
main(){
    int num1,num2,i,j,sum1=0,sum2=0;
    printf("enter two numbers :\n");
    scanf("%d%d",&num1,&num2);
    for(i = 1; i <= num1 / 2; i++)
   {
        if(num1 % i ==0)
            sum1 = sum1 + i ;
    }
    for(j = 1; i <= num2 / 2; i++)
   {
        if(num2 % i ==0)
            sum2 = sum2 + i ;
    }
    if(num1 == sum2 && num2 == sum1)
        print("\n numbers are amicable");
    else
        print("\n numbers are not amicable");
}

Output :-

enter two numbers :
220
284
numbers are amicable

Algorithm to Check Whether Two Numbers are Amicable or Not


Step 1 : Start
Step 2 : Read Num1, Num2
Step 3 :  i = 1
Step 4 : if  i <=  Num1 / 2 then go to Step 5 
             else go to Step 8
Step 5 : if  Num1 % i = 0 then go to Step 6
             else go to Step 7
Step 6 : Sum1 = Sum1 + i
Step 7 : i = i + 1 , then  go to Step 4
Step 8 : i = 1
Step 9 : if  i <=  Num2 / 2 then go to Step 10 

             else go to Step 13
Step 10 : if  Num2 % i = 0 then go to Step 11
             else go to Step 12
Step 11 : Sum2 = Sum2 + i

Step 12 : i = i + 1 , then  go to Step 9
Step 13 : if Sum1 = Num2 and Sum2 = Num1 then go to Step 14
               else go to Step 15 
Step 14 : print "Numbers are Amicable" ,go to Step 16
Step 15 : print "Numbers are not amicable" ,go to Step 16
Step 16 : Stop 

How to Invert an SVG image using CSS ?

You can invert your svg easily by using following css code svg { -webkit-filter: invert(100%); /* safari 6.0 - 9.0 */ filter...