Write a Program to take integer as input & find out all its divisor & sum of Divisor .
Algorithm :
Simply make a for loop & check for each no . Is it divider of given no or not . IF it is divider of given no add to sum.
C PRogram :
#include<stdio.h>
int div_sum(int b) //funtion def
{
int i=1,sum=0;
printf("divisor are : ");
for(i=1;i<b;++i)
{
if(b%i==0)
{
printf(" %d ",i);
sum=sum+i; // save
} }
return(sum);
}
int main()
{
int a,m;
printf(" inter an Integer no. : ");
scanf("%d",&a);
m=div_sum(a);
printf("sum is = %d",m);
}
Hi, I wish for to subscribe for this blog to get hottest updates, so where can i do
ReplyDeleteiit please assist.
Feel free to surf to mmy web site; Xbox-Live-Code-Generator