0

Can anyone please tell me the answer to this question : Q - print the sum of odd and even numbers separately from the loop

22nd Dec 2022, 2:00 PM
Sanya Sanskriti
Sanya Sanskriti - avatar
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();
23rd Dec 2022, 8:21 AM
Jayakrishna 🇼🇳
+ 1
Where is your attempt?
22nd Dec 2022, 2:05 PM
KrOW
KrOW - avatar
22nd Dec 2022, 2:20 PM
Sanya Sanskriti
Sanya Sanskriti - avatar
+ 1
Where is the problem? It seem run in correct way
22nd Dec 2022, 2:22 PM
KrOW
KrOW - avatar
+ 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.)
22nd Dec 2022, 2:28 PM
Sanya Sanskriti
Sanya Sanskriti - avatar
+ 1
I just said 10 as an example. I don't actually want it as 10.
23rd Dec 2022, 3:09 PM
Sanya Sanskriti
Sanya Sanskriti - avatar
+ 1
Thank you anyways. The output came .
23rd Dec 2022, 3:11 PM
Sanya Sanskriti
Sanya Sanskriti - avatar
+ 1
String output= String.format("%d %d", sumO, sumE); System.out.println(output);
23rd Dec 2022, 3:14 PM
KrOW
KrOW - avatar