+ 1
How to print even numbers without using any loopin java??only in 15 lines..
6 odpowiedzi
+ 3
Let's assume by "how" you mean logic not the code itself.
Try making it by yourself for better Practice.
You have to use recursive function to print even numbers without loop.
Here goes the logic, create a function, check if argument is less then whatever end point you want to print upto e.g. 20, 30, 40 . . .
Then check if argument variable % 2 is zero or not so you will get if it's even or odd.
Print it if even else just call the function itself with argument + 1
+ 1
Asrar Ali How you can say only in 15 lines. I think you know the logic. 😁😁
+ 1
Asrar Ali Can you show your code?
0
Thanks bro, i try myself thanks for help
0
Na bro i try myself but i cant
0
This question should've tagged 'Java' instead of 'hasnain'.