+ 1
Print Even Number in Java
How To write a Program using for loop to print Even Numbers from 1 to 25.
8 ответов
+ 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 🤙🤙
+ 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 🤙🤙
+ 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;
}
+ 2
in python with lambda:
print(list(filter(lambda x: x % 2 == 0, range(1,26))))
+ 2
In Java.
+ 2
Yupp.
+ 1
Similar Program to Print Odd Numbers.
+ 1
Thankyou so much 😊.