Saturday, 27 July 2013

C-Program To Find SUM of Natural Numbers Divisible by a Number Given By user Upto a Limit

#include<stdio.h>
main ()
{
int sum=0,n,i,d;
printf("Enter the Limit\t");
scanf("%d",&n);
printf("Enter the Divisible\t");
scanf("%d",&d);
for(i=d;i<=n;i=i+d)
{
if(i%d==0)
{
sum=sum+i;
}
}
printf("Sum of Numbers Divisible By %d upto %d is %d",d,n,sum);
}





sakoncepts.blogspot.com
output

No comments:

Post a Comment