Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.c > #7507 > unrolled thread

what is the output?

Started byvinay kumar <vinay5b9@gmail.com>
First post2011-07-03 09:34 -0700
Last post2011-07-07 17:33 +0300
Articles 18 — 13 participants

Back to article view | Back to comp.lang.c


Contents

  what is the output? vinay kumar <vinay5b9@gmail.com> - 2011-07-03 09:34 -0700
    Re: what is the output? "osmium" <r124c4u102@comcast.net> - 2011-07-03 11:57 -0500
    Re: what is the output? Vincenzo Mercuri <vincenzo.mercuri@yahoo.it> - 2011-07-03 19:05 +0200
      Re: what is the output? Vincenzo Mercuri <vincenzo.mercuri@yahoo.it> - 2011-07-03 19:18 +0200
        Re: what is the output? Vincenzo Mercuri <vincenzo.mercuri@yahoo.it> - 2011-07-03 19:22 +0200
    Re: what is the output? Geoff <geoff@invalid.invalid> - 2011-07-03 12:31 -0700
    Re: what is the output? Joe Pfeiffer <pfeiffer@cs.nmsu.edu> - 2011-07-03 14:08 -0600
      Re: what is the output? Hans Vlems <hvlems@freenet.de> - 2011-07-03 23:33 -0700
        Re: what is the output? Dr Nick <3-nospam@temporary-address.org.uk> - 2011-07-04 08:17 +0100
          Re: what is the output? Keith Thompson <kst-u@mib.org> - 2011-07-04 14:33 -0700
            Re: what is the output? James Kuyper <jameskuyper@verizon.net> - 2011-07-04 19:14 -0400
              Re: what is the output? Chad <cdalten@gmail.com> - 2011-07-05 10:59 -0700
                Re: what is the output? Keith Thompson <kst-u@mib.org> - 2011-07-05 11:18 -0700
                Re: what is the output? Todd Carnes <toddcarnes@gmail.com> - 2011-07-05 18:23 +0000
              Re: what is the output? James Kuyper <jameskuyper@verizon.net> - 2011-07-05 23:00 -0400
        Re: what is the output? Joe Pfeiffer <pfeiffer@cs.nmsu.edu> - 2011-07-04 07:25 -0600
        Re: what is the output? Willem <willem@turtle.stack.nl> - 2011-07-04 15:11 +0000
          Re: what is the output? Phil Carmody <thefatphil_demunged@yahoo.co.uk> - 2011-07-07 17:33 +0300

#7507 — what is the output?

Fromvinay kumar <vinay5b9@gmail.com>
Date2011-07-03 09:34 -0700
Subjectwhat is the output?
Message-ID<080abbae-9aea-4c3e-a504-9ac1b3e01af1@glegroupsg2000goo.googlegroups.com>
main()
{
int d=010;
printf("%d",d);
}

[toc] | [next] | [standalone]


#7508

From"osmium" <r124c4u102@comcast.net>
Date2011-07-03 11:57 -0500
Message-ID<97blcfF93kU1@mid.individual.net>
In reply to#7507
"vinay kumar" wrote:

> main()
> {
> int d=010;
> printf("%d",d);
> }

A leading zero indicates octal. 

[toc] | [prev] | [next] | [standalone]


#7509

FromVincenzo Mercuri <vincenzo.mercuri@yahoo.it>
Date2011-07-03 19:05 +0200
Message-ID<EbednXktC_v2PI3TnZ2dnUVZ8iOdnZ2d@giganews.com>
In reply to#7507
vinay kumar wrote:

> main()
> {
> int d=010;
> printf("%d",d);
> }

#include <stdio.h>

int main(void) {
    int d = 010;
    printf("%o\n", (unsigned int) d);
    return 0;
}

Check the differences.

[toc] | [prev] | [next] | [standalone]


#7510

FromVincenzo Mercuri <vincenzo.mercuri@yahoo.it>
Date2011-07-03 19:18 +0200
Message-ID<486dnUal3YnuOY3TnZ2dnUVZ8rudnZ2d@giganews.com>
In reply to#7509
Vincenzo Mercuri wrote:


>     printf("%o\n", (unsigned int) d);

or rather,

   printf("%0o\n", (unsigned int) d);

if you want to display it in octal form. Just

   printf("%d\n", d);

if you want to convert and display it in decimal base.

[toc] | [prev] | [next] | [standalone]


#7511

FromVincenzo Mercuri <vincenzo.mercuri@yahoo.it>
Date2011-07-03 19:22 +0200
Message-ID<486dnUGl3YmhOI3TnZ2dnUVZ8rudnZ2d@giganews.com>
In reply to#7510
Vincenzo Mercuri wrote:

> Vincenzo Mercuri wrote:
> 
> 
>>     printf("%o\n", (unsigned int) d);
> 
> or rather,
> 
>    printf("%0o\n", (unsigned int) d);

printf("0%o\n", (unsigned int) d);

Gosh, I cannot write it correctly today. I'll make it. 
I better be friend to Knode. 

[toc] | [prev] | [next] | [standalone]


#7517

FromGeoff <geoff@invalid.invalid>
Date2011-07-03 12:31 -0700
Message-ID<vpg117tstiur3793h46htuf7mvq2df9o5o@4ax.com>
In reply to#7507
On Sun, 3 Jul 2011 09:34:33 -0700 (PDT), vinay kumar
<vinay5b9@gmail.com> wrote:

>main()
>{
>int d=010;
>printf("%d",d);
>}

int main(void)
{
	int d = 010;
	printf("%d", d);
}

This sounds like an interview question or a homework problem.
What do you think the output is? Did you compile and run it?

[toc] | [prev] | [next] | [standalone]


#7520

FromJoe Pfeiffer <pfeiffer@cs.nmsu.edu>
Date2011-07-03 14:08 -0600
Message-ID<1b1uy7i0v1.fsf@snowball.wb.pfeifferfamily.net>
In reply to#7507
vinay kumar <vinay5b9@gmail.com> writes:

> main()
> {
> int d=010;
> printf("%d",d);
> }

I don't want to be too rude, but you could compile and run it and find
the output for yourself much faster than you can expect an answer here.

[toc] | [prev] | [next] | [standalone]


#7569

FromHans Vlems <hvlems@freenet.de>
Date2011-07-03 23:33 -0700
Message-ID<fd8edf90-9baa-4b0a-a8ef-30b05fe0004c@g12g2000yqd.googlegroups.com>
In reply to#7520
On 3 jul, 22:08, Joe Pfeiffer <pfeif...@cs.nmsu.edu> wrote:
> vinay kumar <vinay...@gmail.com> writes:
> > main()
> > {
> > int d=010;
> > printf("%d",d);
> > }
>
> I don't want to be too rude, but you could compile and run it and find
> the output for yourself much faster than you can expect an answer here.

My guess is that the OP did do that. And it failed to compile because
printf
wasn't defined. If the OP had managed to find the answer to that in
his textbook then the
question would never have arrived here.
I seriously doubt the OP is interested in niceties as main() vs.
main(void) or int main(void).
Hans

[toc] | [prev] | [next] | [standalone]


#7571

FromDr Nick <3-nospam@temporary-address.org.uk>
Date2011-07-04 08:17 +0100
Message-ID<87vcvio6pr.fsf@temporary-address.org.uk>
In reply to#7569
Hans Vlems <hvlems@freenet.de> writes:

> On 3 jul, 22:08, Joe Pfeiffer <pfeif...@cs.nmsu.edu> wrote:
>> vinay kumar <vinay...@gmail.com> writes:
>> > main()
>> > {
>> > int d=010;
>> > printf("%d",d);
>> > }
>>
>> I don't want to be too rude, but you could compile and run it and find
>> the output for yourself much faster than you can expect an answer here.
>
> My guess is that the OP did do that. And it failed to compile because
> printf
> wasn't defined. If the OP had managed to find the answer to that in
> his textbook then the
> question would never have arrived here.
> I seriously doubt the OP is interested in niceties as main() vs.
> main(void) or int main(void).

My guess is he didn't.  My guess is it's our resident troll again.
Let's count shall we:

no #includes
no type for main
no void
no trailing newline on printf
no return from main

5 out of 5.

That's ignoring the actual problem of course.
-- 
Online waterways route planner            | http://canalplan.eu
Plan trips, see photos, check facilities  | http://canalplan.org.uk

[toc] | [prev] | [next] | [standalone]


#7609

FromKeith Thompson <kst-u@mib.org>
Date2011-07-04 14:33 -0700
Message-ID<ln39il4tpu.fsf@nuthaus.mib.org>
In reply to#7571
Dr Nick <3-nospam@temporary-address.org.uk> writes:
> Hans Vlems <hvlems@freenet.de> writes:
>> On 3 jul, 22:08, Joe Pfeiffer <pfeif...@cs.nmsu.edu> wrote:
>>> vinay kumar <vinay...@gmail.com> writes:
>>> > main()
>>> > {
>>> > int d=010;
>>> > printf("%d",d);
>>> > }
>>>
>>> I don't want to be too rude, but you could compile and run it and find
>>> the output for yourself much faster than you can expect an answer here.
>>
>> My guess is that the OP did do that. And it failed to compile because
>> printf
>> wasn't defined. If the OP had managed to find the answer to that in
>> his textbook then the
>> question would never have arrived here.
>> I seriously doubt the OP is interested in niceties as main() vs.
>> main(void) or int main(void).
>
> My guess is he didn't.  My guess is it's our resident troll again.
> Let's count shall we:
>
> no #includes
> no type for main
> no void
> no trailing newline on printf
> no return from main
>
> 5 out of 5.
>
> That's ignoring the actual problem of course.

My guess is that it's simply old code.  IIRC, 4 out of 5 of the
things you count are characteristics of the "hello world" program
in K&R1.

-- 
Keith Thompson (The_Other_Keith) kst-u@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"

[toc] | [prev] | [next] | [standalone]


#7618

FromJames Kuyper <jameskuyper@verizon.net>
Date2011-07-04 19:14 -0400
Message-ID<iuthgq$a1q$1@dont-email.me>
In reply to#7609
On 07/04/2011 05:33 PM, Keith Thompson wrote:
> Dr Nick <3-nospam@temporary-address.org.uk> writes:
...
>> My guess is he didn't.  My guess is it's our resident troll again.
>> Let's count shall we:
>>
>> no #includes
>> no type for main
>> no void
>> no trailing newline on printf
>> no return from main
>>
>> 5 out of 5.
>>
>> That's ignoring the actual problem of course.
> 
> My guess is that it's simply old code.  IIRC, 4 out of 5 of the
> things you count are characteristics of the "hello world" program
> in K&R1.

How about:
no follow-up response.

That's generally a pretty good indicator of our resident troll.
-- 
James Kuyper

[toc] | [prev] | [next] | [standalone]


#7671

FromChad <cdalten@gmail.com>
Date2011-07-05 10:59 -0700
Message-ID<76f4c909-9d5a-42cf-8584-7a341a70d82d@35g2000prp.googlegroups.com>
In reply to#7618
On Jul 4, 4:14 pm, James Kuyper <jameskuy...@verizon.net> wrote:
> On 07/04/2011 05:33 PM, Keith Thompson wrote:
>
>
>
>
>
> > Dr Nick <3-nos...@temporary-address.org.uk> writes:
> ...
> >> My guess is he didn't.  My guess is it's our resident troll again.
> >> Let's count shall we:
>
> >> no #includes
> >> no type for main
> >> no void
> >> no trailing newline on printf
> >> no return from main
>
> >> 5 out of 5.
>
> >> That's ignoring the actual problem of course.
>
> > My guess is that it's simply old code.  IIRC, 4 out of 5 of the
> > things you count are characteristics of the "hello world" program
> > in K&R1.
>
> How about:
> no follow-up response.
>
> That's generally a pretty good indicator of our resident troll.

So like, I got rejected by UCLA three times in a row and UC Berkeley
like 4 times in a row. Actually, now that I think about it, the people
in the Computer Science Department at UCLA didn't even want to talk to
me this last time around.

[toc] | [prev] | [next] | [standalone]


#7673

FromKeith Thompson <kst-u@mib.org>
Date2011-07-05 11:18 -0700
Message-ID<ln62ng382k.fsf@nuthaus.mib.org>
In reply to#7671
Chad <cdalten@gmail.com> writes:
> On Jul 4, 4:14 pm, James Kuyper <jameskuy...@verizon.net> wrote:
>> On 07/04/2011 05:33 PM, Keith Thompson wrote:
>> > Dr Nick <3-nos...@temporary-address.org.uk> writes:
>> ...
>> >> My guess is he didn't.  My guess is it's our resident troll again.
>> >> Let's count shall we:
>>
>> >> no #includes
>> >> no type for main
>> >> no void
>> >> no trailing newline on printf
>> >> no return from main
>>
>> >> 5 out of 5.
>>
>> >> That's ignoring the actual problem of course.
>>
>> > My guess is that it's simply old code.  IIRC, 4 out of 5 of the
>> > things you count are characteristics of the "hello world" program
>> > in K&R1.
>>
>> How about:
>> no follow-up response.
>>
>> That's generally a pretty good indicator of our resident troll.
>
> So like, I got rejected by UCLA three times in a row and UC Berkeley
> like 4 times in a row. Actually, now that I think about it, the people
> in the Computer Science Department at UCLA didn't even want to talk to
> me this last time around.

I can't wait to see how this turns out to be relevant.

-- 
Keith Thompson (The_Other_Keith) kst-u@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"

[toc] | [prev] | [next] | [standalone]


#7674

FromTodd Carnes <toddcarnes@gmail.com>
Date2011-07-05 18:23 +0000
Message-ID<pan.2011.07.05.18.23.52@gmail.com>
In reply to#7671
On Tue, 05 Jul 2011 10:59:40 -0700, Chad wrote:

> So like, I got rejected by UCLA three times in a row and UC Berkeley
> like 4 times in a row. Actually, now that I think about it, the people
> in the Computer Science Department at UCLA didn't even want to talk to
> me this last time around.

Not the type of thing most would brag about...

[toc] | [prev] | [next] | [standalone]


#7691

FromJames Kuyper <jameskuyper@verizon.net>
Date2011-07-05 23:00 -0400
Message-ID<iv0j46$3p9$1@dont-email.me>
In reply to#7618
On 07/04/2011 07:14 PM, James Kuyper wrote:
> On 07/04/2011 05:33 PM, Keith Thompson wrote:
>> Dr Nick <3-nospam@temporary-address.org.uk> writes:
> ...
>>> My guess is he didn't.  My guess is it's our resident troll again.
>>> Let's count shall we:
>>>
>>> no #includes
>>> no type for main
>>> no void
>>> no trailing newline on printf
>>> no return from main
>>>
>>> 5 out of 5.
>>>
>>> That's ignoring the actual problem of course.
>>
>> My guess is that it's simply old code.  IIRC, 4 out of 5 of the
>> things you count are characteristics of the "hello world" program
>> in K&R1.
> 
> How about:
> no follow-up response.

And, for good measure,
No other messages ever posted to usenet using that e-mail address.
-- 
James Kuyper

[toc] | [prev] | [next] | [standalone]


#7588

FromJoe Pfeiffer <pfeiffer@cs.nmsu.edu>
Date2011-07-04 07:25 -0600
Message-ID<1bsjqmnpo7.fsf@snowball.wb.pfeifferfamily.net>
In reply to#7569
Hans Vlems <hvlems@freenet.de> writes:

> On 3 jul, 22:08, Joe Pfeiffer <pfeif...@cs.nmsu.edu> wrote:
>> vinay kumar <vinay...@gmail.com> writes:
>> > main()
>> > {
>> > int d=010;
>> > printf("%d",d);
>> > }
>>
>> I don't want to be too rude, but you could compile and run it and find
>> the output for yourself much faster than you can expect an answer here.
>
> My guess is that the OP did do that. And it failed to compile because
> printf
> wasn't defined. If the OP had managed to find the answer to that in
> his textbook then the
> question would never have arrived here.
> I seriously doubt the OP is interested in niceties as main() vs.
> main(void) or int main(void).
> Hans

Checking...  at least under GCC, it compiles (with a warning due to
printf()), runs, and gives the expected result.

[toc] | [prev] | [next] | [standalone]


#7594

FromWillem <willem@turtle.stack.nl>
Date2011-07-04 15:11 +0000
Message-ID<slrnj13m1g.23ql.willem@turtle.stack.nl>
In reply to#7569
Hans Vlems wrote:
) On 3 jul, 22:08, Joe Pfeiffer <pfeif...@cs.nmsu.edu> wrote:
)> vinay kumar <vinay...@gmail.com> writes:
)> > main()
)> > {
)> > int d=010;
)> > printf("%d",d);
)> > }
)>
)> I don't want to be too rude, but you could compile and run it and find
)> the output for yourself much faster than you can expect an answer here.
)
) My guess is that the OP did do that. And it failed to compile because
) printf
) wasn't defined.
Why do you guess that? My guess is that it never even came near a compiler.

If the OP had managed to find the answer to that in
) his textbook then the
) question would never have arrived here.

True, but if the OP had actually opened his textbook he would have had a
much better chance at finding the answer.

) I seriously doubt the OP is interested in niceties as main() vs.
) main(void) or int main(void).

That is just a stick to hit people with when they post homework questions.

HTH HAND

SaSW, Willem
-- 
Disclaimer: I am in no way responsible for any of the statements
            made in the above text. For all I know I might be
            drugged or something..
            No I'm not paranoid. You all think I'm paranoid, don't you !
#EOT

[toc] | [prev] | [next] | [standalone]


#7840

FromPhil Carmody <thefatphil_demunged@yahoo.co.uk>
Date2011-07-07 17:33 +0300
Message-ID<87pqlm5ff0.fsf@bazspaz.fatphil.org>
In reply to#7594
Willem <willem@turtle.stack.nl> writes:
> Hans Vlems wrote:
> ) On 3 jul, 22:08, Joe Pfeiffer <pfeif...@cs.nmsu.edu> wrote:
> )> vinay kumar <vinay...@gmail.com> writes:
> ) I seriously doubt the OP is interested in niceties as main() vs.
> ) main(void) or int main(void).
> 
> That is just a stick to hit people with when they post homework questions.

It's a stick people wave around, but there's no evidence of any
contact being made.

Phil
-- 
"At least you know where you are with Microsoft."
"True. I just wish I'd brought a paddle." -- Matthew Vernon

[toc] | [prev] | [standalone]


Back to top | Article view | comp.lang.c


csiph-web