Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.c > #7507 > unrolled thread
| Started by | vinay kumar <vinay5b9@gmail.com> |
|---|---|
| First post | 2011-07-03 09:34 -0700 |
| Last post | 2011-07-07 17:33 +0300 |
| Articles | 18 — 13 participants |
Back to article view | Back to comp.lang.c
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
| From | vinay kumar <vinay5b9@gmail.com> |
|---|---|
| Date | 2011-07-03 09:34 -0700 |
| Subject | what is the output? |
| Message-ID | <080abbae-9aea-4c3e-a504-9ac1b3e01af1@glegroupsg2000goo.googlegroups.com> |
main()
{
int d=010;
printf("%d",d);
}
[toc] | [next] | [standalone]
| From | "osmium" <r124c4u102@comcast.net> |
|---|---|
| Date | 2011-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]
| From | Vincenzo Mercuri <vincenzo.mercuri@yahoo.it> |
|---|---|
| Date | 2011-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]
| From | Vincenzo Mercuri <vincenzo.mercuri@yahoo.it> |
|---|---|
| Date | 2011-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]
| From | Vincenzo Mercuri <vincenzo.mercuri@yahoo.it> |
|---|---|
| Date | 2011-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]
| From | Geoff <geoff@invalid.invalid> |
|---|---|
| Date | 2011-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]
| From | Joe Pfeiffer <pfeiffer@cs.nmsu.edu> |
|---|---|
| Date | 2011-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]
| From | Hans Vlems <hvlems@freenet.de> |
|---|---|
| Date | 2011-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]
| From | Dr Nick <3-nospam@temporary-address.org.uk> |
|---|---|
| Date | 2011-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]
| From | Keith Thompson <kst-u@mib.org> |
|---|---|
| Date | 2011-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]
| From | James Kuyper <jameskuyper@verizon.net> |
|---|---|
| Date | 2011-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]
| From | Chad <cdalten@gmail.com> |
|---|---|
| Date | 2011-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]
| From | Keith Thompson <kst-u@mib.org> |
|---|---|
| Date | 2011-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]
| From | Todd Carnes <toddcarnes@gmail.com> |
|---|---|
| Date | 2011-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]
| From | James Kuyper <jameskuyper@verizon.net> |
|---|---|
| Date | 2011-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]
| From | Joe Pfeiffer <pfeiffer@cs.nmsu.edu> |
|---|---|
| Date | 2011-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]
| From | Willem <willem@turtle.stack.nl> |
|---|---|
| Date | 2011-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]
| From | Phil Carmody <thefatphil_demunged@yahoo.co.uk> |
|---|---|
| Date | 2011-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