Don't forget the modulus operator % int x = 15; int y = x%12; y will be the remainder of 15/12 In this case "3". If y is 0 then it is divisible by 12. Other wise you know how far away you are from a multiple of 12 and can round up or down as required.
For a good Prime, call:<br />29819592777931214269172453467810429868925511217482600306406141434158089
Joined: Oct 10, 2002
thanks guys for ur reply,well it works if there is an input below 12 what if the user selects 19 i should be able to check it out and find if its is near to a multiple to 12 eg; 19 is near to 24 29 is near 24 31 is near 36 40 is near 36 44 is near 48
how to check these options?? this all happens when a user selects from the user input? say a user wanna buy apples...he selects these..
Peter gave you this formula: ((value+6)/12)*12 try putting your numbers (value) in that. Do not forget that "/" is integer division (without remainder). [ February 21, 2003: Message edited by: Barry Gaunt ]