Mark Bluemel
4/11/2011 1:00:00 PM
On 04/11/2011 01:37 PM, Malcolm McLean wrote:
> On Apr 9, 5:34 pm, r...@zedat.fu-berlin.de (Stefan Ram) wrote:
>> srikanth<srikanth0...@gmail.com> writes:
>>> I am new to c programing. Recently one of my friend attended a
>>> interview and the interviewer asked a question to write a program
>>> which prints 100 numbers and from those 100 numbers replace multiples
>>> of 3 and 5 with T and F.
>>
>> #include<stdio.h>
>> int main( void ){ for( int i = 0; i< 100; ++i )puts( "1" ); }
>>
>
> It's a bit trickier than it looks because a number can be a multiple
> of both 3 and 5, and it's not specified what the program should do.
> However most probably the user wants a "TF".
> #include<stdio.h>
>
> int main(void)
> {
> int i;
>
> for(i=0;i<100;i++)
> {
> if( (i % 3)&& (i % 5))
> printf("%d ", i);
> else
> {
> if(i % 3)
> printf("T");
> if(i % 5)
> printf("F");
> printf(" ");
> }
> }
> printf("\n");
>
> return 0;
> }
I'm trying to work out whether you've been subtle here or not...