446,193 Members | 826 Online
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

 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
5 Replies

 100+ P: 293 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

 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

 P: 13 THANKS A MILLION ... I APPRECIATE YOUR HELP Q1: ( numberOfPrizes % numberOfParticipants == 0 ); Q2: ( widthOfBox % widthOfBook != 0 ); Oct 1 '06 #5

 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