By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,193 Members | 826 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,193 IT Pros & Developers. It's quick & easy.

I NEED HELP ---- REGARDING "IF" STATEMENT

NewYorker
P: 13
Q1:
Write an expression that evaluates to true if the value of the integer variable numberOfPrizes is divisible (with no remainder) by the integer variable numberOfParticipants . (Assume that numberOfParticipants is not zero.)

Q2:

Write an expression that evaluates to true if the value of the integer variable widthOfBox is not divisible (with a remainder) by the integer variable widthOfBook . (Assume that widthOfBook is not zero.)

Thanks pals.
Sep 30 '06 #1
Share this Question
Share on Google+
5 Replies


100+
P: 293
D_C
Suppose numberOfPrizes = A*numberOfParticipants+R.

R = (numberOfPrizes % numberOfParticipants);
% is the modulo operation. Similarly for WidthOfWhatever.

Use the modulo operation and test if it is 0.

If J divides K, then ((J%K)==0).
Sep 30 '06 #2

P: 23
Q1:
Write an expression that evaluates to true if the value of the integer variable numberOfPrizes is divisible (with no remainder) by the integer variable numberOfParticipants . (Assume that numberOfParticipants is not zero.)

Q2:

Write an expression that evaluates to true if the value of the integer variable widthOfBox is not divisible (with a remainder) by the integer variable widthOfBook . (Assume that widthOfBook is not zero.)

Thanks pals.
Q1: ( numberOfPrizes % numberOfParticipants == 0 );

Q2: ( widthOfBox % widthOfBook != 0 );
Sep 30 '06 #3

NewYorker
P: 13
Our analysis of your code: COMPILER ERRORS

Some suggestions:
Unexpected identifiers: A, R, Suppose
Just write an expression -- not a statement!
There is no need for an assignment operator here.



Suppose numberOfPrizes = A*numberOfParticipants+R.

R = (numberOfPrizes % numberOfParticipants);
% is the modulo operation. Similarly for WidthOfWhatever.

Use the modulo operation and test if it is 0.

If J divides K, then ((J%K)==0).
Oct 1 '06 #4

NewYorker
P: 13
THANKS A MILLION ... I APPRECIATE YOUR HELP

Q1: ( numberOfPrizes % numberOfParticipants == 0 );

Q2: ( widthOfBox % widthOfBook != 0 );
Oct 1 '06 #5

Banfa
Expert Mod 5K+
P: 8,916
Our analysis of your code: COMPILER ERRORS

Some suggestions:
Unexpected identifiers: A, R, Suppose
Just write an expression -- not a statement!
There is no need for an assignment operator here.
That is because D_C did not supply code, they supplied the solution giving you the explaination in English of the operations required and made the reasonable assumption that you would be able to then understand how to solve your problem and write the solution for yourself.

It appears you need to learn to recognise the difference between C and English
Oct 1 '06 #6

Post your reply

Sign in to post your reply or Sign up for a free account.