C-Program To Find SUM of Natural Numbers Divisible By 3 Upto a Limit
#include<stdio.h>
main ()
{
int sum=0,n,i;
printf("Enter the Limit\t");
scanf("%d",&n);
for(i=3;i<=n;i=i+3)
{
if(i%3==0)
{
sum=sum+i;
}
}
printf("Sum of Numbers Divisible By three Upto %d is %d",n,sum);
}
 |
| output |
No comments:
Post a Comment