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++; } } }
You can use the symbol % to see the remainder of the division problem. eg. document.write(11 % 3 + "") will display the number 2 since 3 goes into 11 three times with a remainder of 2. So here's some sample code: function oddEven(num){ if(num % 2 == 0){ return "even" } else{ return "odd" } }
The answer is an odd number.
for(int i = 1; i < 100; i+=2) { System.out.println(i); }
The odd numbers between 14 and 20 are 15, 17, and 19. To find their sum, you add them together: 15 + 17 + 19 = 51. Therefore, the sum of the odd numbers between 14 and 20 is 51.
Between the two numbers there are 49.
There are no odd numbers between 38 and 39, as 39 is the next integer and it is an odd number. Therefore, there are zero odd numbers between 38 and 39.
The smallest odd number between 220 and 940 is 221, while the largest odd number in that range is 939. To find the difference between these two numbers, subtract 221 from 939, which equals 718. Therefore, the difference between the smallest and largest odd numbers between 220 and 940 is 718.
There are 44 odd numbers between the two.
The odd numbers between 40 and 53 are 41,43,45,47,49,51.
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.
There are 1499 odd numbers between 2000 and 4999