Write a small basic program to print the sum of even numbers from 2 to the nmber entered by the user.
Answers
Answered by
0
Answer:
import java.util.*;
class number
{
public static void main()
{
Scanner sc=new Scanner(System.in);
int n,sum=0;
System.out.println(" Enter the limit");
n=sc.nextInt();
if(n%2==0)
{
sum=sum+n;
System.out.println("sum is"+sum);
}
}
}
Similar questions