V
vinay kumar
main()
{
int d=010;
printf("%d",d);
}
please give with explanation
{
int d=010;
printf("%d",d);
}
please give with explanation
vinay said:main()
{
int d=010;
printf("%d",d);
}
please give with explanation
main()
{
int d=010;
printf("%d",d);
}
please give with explanation
Eric Sosman said:Undefined, because a variable-argument function is used
without a prototyped declaration.
Also implementation-defined, because the final line of text
output is not terminated with a newline.
Also either (1) "semi-undefined" because a C90 int-valued
function returns without returning a value, or (2) implementation-
defined because a C99 compiler must diagnose a function definition
without return type, and *if* it translates the program anyhow it
gives it an implementation-defined meaning.
vinay kumar said:main()
{
int d=010;
printf("%d",d);
}
vinay kumar said:main()
{
int d=010;
printf("%d",d);
}
please give with explanation
Undefined, because a variable-argument function is used
without a prototyped declaration.
Also implementation-defined, because the final line of text
output is not terminated with a newline.
Also either (1) "semi-undefined" because a C90 int-valued
function returns without returning a value, or (2) implementation-
defined because a C99 compiler must diagnose a function definition
without return type, and *if* it translates the program anyhow it
gives it an implementation-defined meaning.
... but the answer you're probably looking for is "8", and
the explanation will be found in the low-numbered pages of your
C textbook -- you know, that unopened volume you've been carrying
around. Open it (it won't bite you), and see what it has to say
about "integer constants" or some similar term.
Undefined, because a variable-argument function is used
without a prototyped declaration.
Also implementation-defined, because the final line of text
output is not terminated with a newline.
Also either (1) "semi-undefined" because a C90 int-valued
function returns without returning a value, or (2) implementation-
defined because a C99 compiler must diagnose a function definition
without return type, and *if* it translates the program anyhow it
gives it an implementation-defined meaning.
... but the answer you're probably looking for is "8", and
the explanation will be found in the low-numbered pages of your
C textbook -- you know, that unopened volume you've been carrying
around. Open it (it won't bite you), and see what it has to say
about "integer constants" or some similar term.
Chad said:I know I shouldn't do this, but I'm going to take the bait on this
one. How do you figure the output is the "8".
Did you try running the program? What output did you get?
Eric already explained how to find the explanation: see what your C
textbook (or on-line tutorial, or copy of the standard) says about
integer constants.
....
I got the number "8" after I compiled and ran this code on my Linux
box here at home. I just wasn't clear on why the computer produced the
number "8" and not the number "10".
vinay kumar said:main()
{
int d=010;
printf("%d",d);
}
Re: what is the output
8
please give with explanation
Eric Sosman said:[snip]main()
{
int d=010;
printf("%d",d);
}
please give with explanation
Also either (1) "semi-undefined" because a C90 int-valued
function returns without returning a value, [snip]
Eric Sosman said:[snip]main()
{
int d=010;
printf("%d",d);
}
please give with explanation
Also either (1) "semi-undefined" because a C90 int-valued
function returns without returning a value, [snip]
Actually this aspect's behavior is defined; only the termination
status returned to the host environment is undefined. (Or it is
implementation-defined in a freestanding implementation.)
You can't take 3 from 2, 2 is less than 3,
so you look at the 4 in the eight's place.
Now that's really four 8's, so you make
it three 8's, change an 8 to 8 ones and
add them to the 2 and that gives 1 2 base 8
which is ten base ten and you take away 3 that's 7.
Now instead of 4 in the 8's place, you've got 3
'cause you added 1 (that is to say, 8) to the 2,
but you can't take 7 from 3, so you look at the 64's.
Eric Sosman said:"Sixty-four? How did sixty-four get into this?" I hear you
cry. Well, sixty-four is eight squared, don't you see? "Ask a
silly question ..."
Eric Sosman said:Undefined, because a variable-argument function is used
without a prototyped declaration.
Also implementation-defined, because the final line of text
output is not terminated with a newline.
Also either (1) "semi-undefined" because a C90 int-valued
function returns without returning a value, or (2) implementation-
defined because a C99 compiler must diagnose a function definition
without return type, and *if* it translates the program anyhow it
gives it an implementation-defined meaning.
... but the answer you're probably looking for is "8", and
the explanation will be found in the low-numbered pages of your
C textbook -- you know, that unopened volume you've been carrying
around. Open it (it won't bite you), and see what it has to say
about "integer constants" or some similar term.
Tim Rentsch said:You can't take 3 from 2, 2 is less than 3,
so you look at the 4 in the eight's place.
Now that's really four 8's, so you make
it three 8's,
[...]change an 8 to 8 ones and
add them to the 2 and that gives 1 2 base 8
which is ten base ten and you take away 3 that's 7.
main()
{
int d=010;
printf("%d",d);
}
please give with explanation
Chad said:I got the number "8" after I compiled and ran this code on my Linux
box here at home. I just wasn't clear on why the computer produced the
number "8" and not the number "10".
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.