The program was complied using Netbeans IDE .
PROGRAM:
package intby7; import java.io.*; public class intby7 { public static void main(String[] args)throws IOException { BufferedReader st=new BufferedReader(new InputStreamReader(System.in)); try { System.out.println("Enter the no from"); int no=Integer.parseInt(st.readLine()); System.out.println("Enter the no to"); int nn=Integer.parseInt(st.readLine()); int sum=0; for(int i=no;i<nn;i++) { int rem=i%7; if(rem==0) { System.out.println(i); sum=sum+i; } } System.out.println("The sum of integer between "+no+" and "+nn+" is "+sum); } catch(Exception e) { } } }
OUTPUT:
Enter the no from 100 Enter the no to 200 105 112 119 126 133 140 147 154 161 168 175 182 189 196 The sum of integer between 100 and 200 is 2107
0 comments:
Post a Comment
If You Are Asking Some Question On This Comment Then Click On Subscribe by email Link