1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
/* List Even Numbers Java Example This List Even Numbers Java Example shows how to find and list even numbers between 1 and any given number. */ public class ListEvenNumbers { public static void main(String[] args) { //define limit int limit = 50; System.out.println("Printing Even numbers between 1 and " + limit); for(int i=1; i <= limit; i++){ // if the number is divisible by 2 then it is even if( i % 2 == 0){ System.out.print(i + " "); } } } } /* Output of List Even Numbers Java Example would be Printing Even numbers between 1 and 50 2 4 6 8 10 12 14 16 18 20 22 24 26 28 30 32 34 36 38 40 42 44 46 48 50 */ |
how to add the even numbers and display the sum???…can you teach me???
int sum=0;
for(int i=1;i<=50;i++)
{
if(i%2==0)
sum+=1
}
System.out.println(sum);
int sum=0;
for(int i=1;i<=50;i++)
{
if(i%2==0)
sum=sum+i;
}
System.out.println(sum);
write a java program to print the even numbers in recursive method……..please
no need of sum+=1. you can directly print them
teach me how to doggy teach teach how to fuck u madafaka
hello i want to know the runtime value declaration like ,, programe for multiplication but we hve to give the value(tabel of 3) at run time . could u help me
How about if the user will put the starting number and the limit? O.0