944,038 Members | Top Members by Rank

Ad:
  • C Discussion Thread
  • Unsolved
  • Views: 461
  • C RSS
Oct 16th, 2009
0

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

Expand 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?
Similar Threads
Reputation Points: 5
Solved Threads: 0
Newbie Poster
needhelpe is offline Offline
22 posts
since Oct 2009
Oct 16th, 2009
0
Re: NEED help TO PUT THE FOLLOWING: IF((N == 2) && (T CAN'T BE DIVIDED BY 4))
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.
Reputation Points: 453
Solved Threads: 57
Posting Virtuoso
twomers is offline Offline
1,873 posts
since May 2007
Oct 16th, 2009
0
Re: NEED help TO PUT THE FOLLOWING: IF((N == 2) && (T CAN'T BE DIVIDED BY 4))
>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.
Reputation Points: 2125
Solved Threads: 243
Postaholic
tux4life is offline Offline
2,105 posts
since Feb 2009
Oct 16th, 2009
0
Re: NEED help TO PUT THE FOLLOWING: IF((N == 2) && (T CAN'T BE DIVIDED BY 4))
Click to Expand / Collapse  Quote originally posted by needhelpe ...
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 %
Reputation Points: 499
Solved Threads: 367
Postaholic
gerard4143 is offline Offline
2,197 posts
since Jan 2008
Oct 16th, 2009
-1

I think this will work..

If (N ==! 2) && (T/4)
{
//Code
}
Reputation Points: 10
Solved Threads: 0
Newbie Poster
shuva is offline Offline
1 posts
since Oct 2009

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in C Forum Timeline: removing white spaces
Next Thread in C Forum Timeline: Determine if a string is a directory name, file name or trash.





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC