Sunday, 22 April 2012

Sum of integers between 100 to 200 divisible by 7


/* Write a program to find sum of all integers greater than 100 and
   less than 200 that are divisible by 7 */
class SumOfDigit{
      public static void main(String args[]){
      int result=0;
      for(int i=100;i<=200;i++){
  
         if(i%7==0)
              result+=i;
      }
      System.out.println("Output of Program is : "+result);
   }

1 comment:

  1. public class Practical6
    {


    public static void main(String[] args)
    {
    int sum=0;
    System.out.println("All no. between 100 to 200 which is divisable by 7");
    for(int i=101; i<200; i++)
    {
    if(i%7==0)
    {
    System.out.println(i);
    sum+=i;
    }
    }
    System.out.println("Sum is: "+sum);
    }

    }

    ReplyDelete