import java.io.*;
class aeven
{
public static void main(String[] args)
{
try{
BufferedReader br1 = new BufferedReader(new InputStreamReader(System.in));
System.out.println("Enter 1st number : ");
int num1 = Integer.parseInt(br1.readLine());
System.out.println("Enter 2nd number : ");
int num2 = Integer.parseInt(br1.readLine());
System.out.println("Odd Numbers : ");
for (int i=num1;i <=num2 ; i++)
{
if(i%2!=0 )
{
System.out.print(i+ ", ");
}
}
}
catch(Exception e){}
}
}
int sum = 0; for (int i = 51; i < 200; i = i + 2){ sum += i; } return sum;
Q.1 Write a program to print first ten odd natural numbers. Q.2 Write a program to input a number. Print their table. Q.3 Write a function to print a factorial value.
public class apples { public static void main(String argc[]) { for(int i = 0; i <= 50; i++){ if(i % 2 != 0){ System.out.println(i); } } } }
It is actually quite easy to write a program in java to do this. The easiest way to do this that I can think of is to use the remainder operator (%) to test whether a number is odd or not. Here is a simple program that will print out all the odd numbers between 1 and 50. public class OddNumbers { public static void main(String[] args) { int i=1; while(i < 50) { if(i%2 != 0) { System.out.println(i); } i++; } } }
Java, Smalltalk, and Eiffel are all object-oriented languages; Lisp is functional.
The answer is an odd number.
for(int i = 1; i < 100; i+=2) { System.out.println(i); }
Between the two numbers there are 49.
The odd numbers between 40 and 53 are 41,43,45,47,49,51.
There are 44 odd numbers between the two.
there are 3.... 7,9,11
You can't find five odd numbers that add up to fifty; the sum of five odd numbers will always be odd.
There are 40 odd numbers between 20 and 100. Remember that an odd number is every second number. There are 80 numbers between 20 and 100, so there are 40 odd numbers and 40 even numbers.
The difference is an even number.
There are 1499 odd numbers between 2000 and 4999
There are 69 odd numbers between 20 and 158.
There are 20 odd numbers between 19 and 57