Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C Programming > what is the output?

Reply
Thread Tools

what is the output?

 
 
vinay kumar
Guest
Posts: n/a
 
      07-03-2011
main()
{
int d=010;
printf("%d",d);
}
 
Reply With Quote
 
 
 
 
osmium
Guest
Posts: n/a
 
      07-03-2011
"vinay kumar" wrote:

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


A leading zero indicates octal.


 
Reply With Quote
 
 
 
 
Geoff
Guest
Posts: n/a
 
      07-03-2011
On Sun, 3 Jul 2011 09:34:33 -0700 (PDT), vinay kumar
<> 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?
 
Reply With Quote
 
Joe Pfeiffer
Guest
Posts: n/a
 
      07-03-2011
vinay kumar <> 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.
 
Reply With Quote
 
Hans Vlems
Guest
Posts: n/a
 
      07-04-2011
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
 
Reply With Quote
 
Dr Nick
Guest
Posts: n/a
 
      07-04-2011
Hans Vlems <> 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
 
Reply With Quote
 
Joe Pfeiffer
Guest
Posts: n/a
 
      07-04-2011
Hans Vlems <> 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.
 
Reply With Quote
 
Willem
Guest
Posts: n/a
 
      07-04-2011
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
 
Reply With Quote
 
Keith Thompson
Guest
Posts: n/a
 
      07-04-2011
Dr Nick <3-> writes:
> Hans Vlems <> 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- <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"
 
Reply With Quote
 
James Kuyper
Guest
Posts: n/a
 
      07-04-2011
On 07/04/2011 05:33 PM, Keith Thompson wrote:
> Dr Nick <3-> 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
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off




Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57