write a program to find the product of first 10 odd numbers using the for loop in java
Answers
Answered by
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);
}
}
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
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!!
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
Similar questions