C Code 11 _ To print the abundant numbers with in the given range



C Code 11 _ To print the abundant numbers with in the given range


Program:


#include<stdio.h>
int main()
{
                int n,i,j,a;
                printf("Enter a number to find the abundant numbers from 1 to the given number : ");
                scanf("%d",&n);
                printf("\nThe abundant numbers from 1 to %d are : ",n);
                for(i=1;i<=n;i++)
                {
                                a=0;
                                for(j=1;j<i;j++)
                                {
                                                if(i%j==0)
                                                {
                                                                a=a+j;
                                                }
                                }
                                if(a>j)
                                {
                                                printf("%d ",j); 
                                }
                }
                return 0;
}




Output:








Thank You ...

Previous Post
Next Post
Related Posts

0 comments:

Popular Posts