Computer Science, asked by muskan481367, 1 year ago

write programming in java to print odd number between 1 and50​

Answers

Answered by arunima0007
5

Explanation:

class bj

{

public static void main(int n)

{

int n>=1 && n<=50;

if n/2 !=0

System.out.println("the no. is odd")

}

}


arunima0007: welcome
muskan481367: with output
arunima0007: output on computer
muskan481367: yes program with output
arunima0007: output toh computer dega ...i gave u the program...try it
muskan481367: ok
muskan481367: please help me this program
muskan481367: java program to print a table of the given number
arunima0007: i gave u....write it on bluej and compile it.....the ans will cme
muskan481367: ok
Answered by sswaraj04
2

Answer:

public class Main {

 public static void main(String[] args) {

  for(int i=1;i<50;i++)

  if(i%2!=0)

  System.out.print(i+" ");

     

 }

}

Explanation:

Simple logic

use iteration from 1 to 50

now check fro odd no each time

if number is not divisible by 2 i.e i%2!=0

print it

Hope it helps :-)

Similar questions