View Single Post
  #3 (permalink)  
Old 07-19-2007, 08:33 PM
cruxblack cruxblack is offline
Senior Member
 
Join Date: Jul 2007
Posts: 130
cruxblack will become famous soon enough
calculates da products of odd numbers from 1-15?

products in da mathematical terms of multiplication u mean rite?
so i supposed u want to make it like this?

1x3x5x7x9x11x13x15 = ?

if u wanna get da odd number from 1 - 15, u could use da modulus operator %, a loop, and an if logical statement

da main method should look like this inside i think

Code:
int x = 1; for(int i=1;i<=15;i++) { if((i%2)==1)//meaning that its an odd number { x = i*x;//or u could just write it x*=i to make it short, but its not really a good idea if ur still stufying, itll give u some hard time reading n doin ur logic } }
btw, just in case it didn't work, make sure u put da code inside da main method k, i already tested da code n it run out just fine

logic comes first, coding comes later
hope this helps sylvia
Reply With Quote