Monday, February 3, 2020

Sum of N numbers which are divisible by 5

Sum of N numbers which are divisible by 5

#include<stdio.h>
int main() {
    int a,sum=0,i=1;
    scanf("%d",&a);
    while(i<=a)
    {
        if(i%5==0)
        {
        sum=sum+i;
        }
        i++;
        
    }
    printf("%d",sum);
        
return 0;
}


Output:


Enter Number:100                                                                                                      
1050                                                                                                                  
       



No comments:

Post a Comment