Computer Science, asked by rashi61, 1 year ago

write a program to find the product of first 10 odd numbers using the for loop in java

Answers

Answered by maria9
4
import java. io;
class odd
{
public static void main (String args[] )
{
scanner Sc = new scanner ( )
int f=1 , i ;
for (i=1 ; i< = 20 ; i ++)
{
if( i%2 == 0 )
{
f=f * i ;
}
}
System. out. print (" the product = " + f);
}
}
Answered by Incredible29
5
hey
here's your answer!!

public class Product
{
public static void main(String args[ ])
{
int a, b = 1;
for (a = 1; a<= 20; a= a +2)
b = b * a ;
System.out.println ("the product of first 10 odd numbers:" + b);
}
}
}

hope it helps!!

rashi61: output but i need in step by step
Incredible29: output is 654729075
rashi61: ok thanks let me try
rashi61: thank u so much
Incredible29: welcy
maria9: ur program is wrong
maria9: plz include odd even checking
Incredible29: not asked
maria9: it is said product of " ODD " numbers
rashi61: ya she is right
Similar questions