can any one tell me how to go to next step.
Thanks in advance.
Sounds like a homework problem. What are you supposed to print when
the number is a multiple of both three and five.
Clue: modulo operator.
I thought so.
#include <stdio.h>
int main (int argc, const char * argv[])
{
int i;
for (i = 1; i <= 100; i++)
{
if (i % 3 == 0 && i % 5 == 0)
printf("TF\n");
else if (i % 3 == 0)
printf("T\n");
else if (i % 5 == 0)
printf("F\n");
else
printf("%i\n", i);
}
return 0;
}
Now, what did you learn from this exercise?
What does % do?
What does && mean?
What does == mean?
Why do we write "if (i % 3 == 0)" and not "if (!i % 3)"?
Can this function be simplfied?
He's learned that he can get someone else to do his homework for him
just by asking.
--
Keith Thompson (The_Other_Keith) ks...@mib.org <http://www.ghoti.net/~kst>
Nokia
"We must do something. This is something. Therefore, we must do this."
-- Antony Jay and Jonathan Lynn, "Yes Minister"
>Geoff <ge...@invalid.invalid> writes:
>> On Mon, 4 Apr 2011 20:45:31 -0700 (PDT), srikanth
>> <srikan...@gmail.com> wrote:
>[...]
>>>Hello Geoff,
>>>Thanks for your reply.
>>>It should print T and F for multiples of 3 and 5.
>>
>> I thought so.
>>
>[code snipped]
>>
>> Now, what did you learn from this exercise?
>[...]
>
>He's learned that he can get someone else to do his homework for him
>just by asking.
It's all part of my diabolical plan to create an army of
cargo-cultists and copy-pasters who can't create an original program
or write good code. They will get good grades in school by stealing
other people's work, get well-paying jobs in foreign locations and
write crap applications, spoiling their products and diminishing
profits, thereby making domestic programmers look better, saving jobs
for America.
"Designed by a few guys at Apple, manufactured for pennies by
thousands in China. Bringing vast profits to a company that hasn't
paid a shareholder dividend since 1995."