Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
Sum of EVEN and ODD nubmers (11 grade)
//Shadiyar Tazhgurazov 24.01.2022 import java.util.*; import java.lang.*; class Rextester { public static void main(String args[]) { int len; int odd=0, even=0; Scanner sc=new Scanner(System.in); System.out.println("Enter Array length : "); len=sc.nextInt(); int a[]=new int[len]; //declaration of array System.out.print("Enter " + len + " Element to Store in Array :\n"); for(int i=0; i<len; i++) { a[i] = sc.nextInt(); } System.out.print("Elements in Array are :\n"); for(int i=0; i<len; i++) { System.out.print(a[i] + " "); } for(int i=0; i<len; i++) { if (a[i] % 2 == 0 ) even=even+a[i]; else odd=odd+a[i]; } System.out.println(""); System.out.println("Sum of EVEN numbers = "+even); System.out.println("Sum of ODD numbers = "+odd); } }
run
|
edit
|
history
|
help
0
javaLP(Multi)
age1
練習問題
Municipiu_Problema_2_Palindrome
Dynamic Array
hello_world_test
Cyclically rotate array
// Java Coding Challenge - 08: Reversing a Number using Mathematical Operations
java palindrome check
home by stars