473,387 Members | 2,436 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

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

NewYorker
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
5 7664
D_C
293 100+
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
m013690
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
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
THANKS A MILLION ... I APPRECIATE YOUR HELP

Q1: ( numberOfPrizes % numberOfParticipants == 0 );

Q2: ( widthOfBox % widthOfBook != 0 );
Oct 1 '06 #5
Banfa
9,065 Expert Mod 8TB
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

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

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.