+ 1

Print Even Number in Java

How To write a Program using for loop to print Even Numbers from 1 to 25.

28th Apr 2019, 12:02 PM
Zain Ul Abdeen
Zain Ul Abdeen - avatar
8 Respuestas
+ 9
IN JAVA: -👇👇👇 public class Program { public static void main(String[] args) { for (int i = 1; i <= 25; i++) { if (i % 2 == 1) { System.out.println(i); } } } } hope u got the answer 🤙🤙
28th Apr 2019, 12:44 PM
Mohd Abdul Sameer
Mohd Abdul Sameer - avatar
+ 10
IN JAVA: -👇👇👇 public class Program { public static void main(String[] args) { for (int i = 1; i <= 25; i++) { if (i % 2 == 0) { System.out.println(i); } } } } hope u got the answer 🤙🤙
28th Apr 2019, 12:37 PM
Mohd Abdul Sameer
Mohd Abdul Sameer - avatar
+ 8
IN PYTHON: -👇👇👇 for i in range (1, 25): if i%2==0: print(i) ------------------------------------------------------------------ IN C: -👇👇👇 #include <stdio.h> int main() { int i=1; for(i;i<=25;i++){ if (i%2==0){ printf("%d\n",i); } } return 0; }
28th Apr 2019, 12:12 PM
Mohd Abdul Sameer
Mohd Abdul Sameer - avatar
+ 2
in python with lambda: print(list(filter(lambda x: x % 2 == 0, range(1,26))))
28th Apr 2019, 12:23 PM
Lothar
Lothar - avatar
+ 2
In Java.
28th Apr 2019, 12:35 PM
Zain Ul Abdeen
Zain Ul Abdeen - avatar
+ 2
Yupp.
28th Apr 2019, 12:44 PM
Zain Ul Abdeen
Zain Ul Abdeen - avatar
+ 1
Similar Program to Print Odd Numbers.
28th Apr 2019, 12:41 PM
Zain Ul Abdeen
Zain Ul Abdeen - avatar
+ 1
Thankyou so much 😊.
28th Apr 2019, 12:45 PM
Zain Ul Abdeen
Zain Ul Abdeen - avatar