what is the output?

G

Geoff

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?
 
J

Joe Pfeiffer

vinay kumar said:
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.
 
H

Hans Vlems

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
 
D

Dr Nick

Hans Vlems said:
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.
 
J

Joe Pfeiffer

Hans Vlems said:
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.
 
W

Willem

Hans Vlems wrote:
)> > 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
 
K

Keith Thompson

Dr Nick said:
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.
 
J

James Kuyper

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.
 
C

Chad

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.
 
K

Keith Thompson

Chad said:
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.
 
T

Todd Carnes

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...
 
P

Phil Carmody

Willem said:
Hans Vlems wrote:
) 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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,952
Messages
2,570,111
Members
46,691
Latest member
Wilhemina5

Latest Threads

Top