NEED help TO PUT THE FOLLOWING: IF((N == 2) && (T CAN'T BE DIVIDED BY 4))

Reply

Join Date: Oct 2009
Posts: 21
Reputation: needhelpe is an unknown quantity at this point 
Solved Threads: 0
needhelpe needhelpe is offline Offline
Newbie Poster

NEED help TO PUT THE FOLLOWING: IF((N == 2) && (T CAN'T BE DIVIDED BY 4))

 
0
  #1
Oct 16th, 2009
HEY I JUST NEED TO PUT THE FOLLOWING:

IF((N == 2) && (T CAN'T BE DIVIDED BY 4))

how can I put: CAN'T BE DIVIDED BY 4?

I know divided by 4 is : (t / 4).

but can not be divided by 4?
Reply With Quote Quick reply to this message  
Join Date: May 2007
Posts: 1,859
Reputation: twomers has a spectacular aura about twomers has a spectacular aura about twomers has a spectacular aura about 
Solved Threads: 55
twomers's Avatar
twomers twomers is offline Offline
Posting Virtuoso
 
0
  #2
Oct 16th, 2009
Most things can be divided. Do you mean is divided with no remainder?
The modulus operator is your friend here.
  1. for ( i=0; i<10; i++ ) {
  2. printf( "%d mod 4 = ", i, i%4 );
  3. }
It returns 0 if no remainder would be returned on division.
I blag!?
"Mr Kitty, you have to live in the attic now. Here, write a diary."
I am the Walrus!
Reply With Quote Quick reply to this message  
Join Date: Feb 2009
Posts: 1,968
Reputation: tux4life has a reputation beyond repute tux4life has a reputation beyond repute tux4life has a reputation beyond repute tux4life has a reputation beyond repute tux4life has a reputation beyond repute tux4life has a reputation beyond repute tux4life has a reputation beyond repute tux4life has a reputation beyond repute tux4life has a reputation beyond repute tux4life has a reputation beyond repute tux4life has a reputation beyond repute 
Solved Threads: 214
tux4life's Avatar
tux4life tux4life is offline Offline
Posting Virtuoso
 
0
  #3
Oct 16th, 2009
>how can I put: CAN'T BE DIVIDED BY 4?
  1. if( (N == 2) && (T % 4) )
  2. {
  3. /* Your code here */
  4. }
Last edited by tux4life; Oct 16th, 2009 at 4:20 pm.
"Never argue with idiots, they just drag you down to their level and then beat you with experience."
Reply With Quote Quick reply to this message  
Join Date: Jan 2008
Posts: 346
Reputation: gerard4143 is on a distinguished road 
Solved Threads: 44
gerard4143's Avatar
gerard4143 gerard4143 is offline Offline
Posting Whiz
 
0
  #4
Oct 16th, 2009
Originally Posted by needhelpe View Post
HEY I JUST NEED TO PUT THE FOLLOWING:

IF((N == 2) && (T CAN'T BE DIVIDED BY 4))

how can I put: CAN'T BE DIVIDED BY 4?

I know divided by 4 is : (t / 4).

but can not be divided by 4?
Use the modulus operator %
Reply With Quote Quick reply to this message  
Join Date: Oct 2009
Posts: 1
Reputation: shuva is an unknown quantity at this point 
Solved Threads: 0
shuva shuva is offline Offline
Newbie Poster

I think this will work..

 
-1
  #5
Oct 16th, 2009
If (N ==! 2) && (T/4)
{
//Code
}
Reply With Quote Quick reply to this message  
Reply

Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC