0
Can anyone please tell me the answer to this question : Q - print the sum of odd and even numbers separately from the loop
8 Answers
+ 2
So you are taking values 0 to 10 for input 10. Then why to take it through input. Just write :
a[i] = i ;
// instead of a[i] = s.nextInt();
+ 1
Where is your attempt?
+ 1
Where is the problem? It seem run in correct way
+ 1
Yes it does but, I want the output in this formatđ
(If the input is 10 then the sum of odd no. and the sum of even no. ; both separated from each other)
25(sum of odd nos.) 20(sum of even nos.)
+ 1
I just said 10 as an example. I don't actually want it as 10.
+ 1
Thank you anyways. The output came .
+ 1
String output= String.format("%d %d", sumO, sumE);
System.out.println(output);