Program to find sum of all numbers between min and max which are divisible by 7 using pointer

This C program finds sum of all numbers between min and max which are divisible by 7 using pointer.

C Source Code: sum of numbers which are divisible by 7 using pointer


#include<stdio.h>

int main()
{
 int min, max, sum=0, i, *minptr, *maxptr;
 /* Referencing */
 minptr = &min;
 maxptr = &max;

 /* Now minptr points to min and maxptr points to max, 
    so in scanf we can use minptr and maxptr instead 
    of &min and &max */

 printf("Enter min and max:\n");
 scanf("%d%d", minptr, maxptr);

 /* Finding sum */
 printf("Numbers are:\n");
 for(i=*minptr ; i<=*maxptr ; i++)
 {
  if(i%7==0)
  {
   printf("%d\t", i);
   sum += i;
  }
 }
 printf("\nSum = %d", sum);

 return 0;
}

Output

Enter min and max:
1↲
30↲
Numbers are:
7    14    21    28
Sum = 70