Code Effect

  • Thread starter Daniel Antonson
  • Start date
W

Walter Roberson

Obviously the given code would not compile on any comipler because of
missing header and all & we are assumed to add that(Mere common sense).
and the code which i compiled was:
#include<stdio.h>
main()
{
char ch;
ch = '7';
printf("%d\n",ch);
return 0;
}
Now is it okay for you.

You extrapolated incorrect code, as you used an improper declaration
of main().

If you are going to extrapolate code anyhow, then why not
extrapolate something slightly different, such as

#define printf(a,b) (b / a[3])

instead of #include <stdio.h> ?

What's that you say, that's not what the original poster intended?
And you know that exactly how?? And since the original question
was obviously some kind of test material, do you presume that
you know the intention of the original test author as well??

Now compile it and it will print "55".

Several people corrected you on that already but you did not appear
to listen. "55" is, at best, the most -common- result of the
program. If the program were run on an EBCDIC system, the result
would be quite different. And in saying that it will print "55"
you missed the newline...
 
C

CBFalconer

Keith said:
.... snip ...

We could argue about whether that point was one worth making, but
let's not.

You must be kidding. Around here that almost guarantees an active
6 month thread, more if some nut cross-posts it.
 
S

sandeep

Walter said:
You extrapolated incorrect code, as you used an improper declaration
of main().
Well i didnt extrapolated the code beacuse if i would comiple that.it
would show some error.
I probably typed incorrectly at that time.
If you are going to extrapolate code anyhow, then why not
extrapolate something slightly different, such as

#define printf(a,b) (b / a[3])

instead of #include <stdio.h> ?

What's that you say, that's not what the original poster intended?
And you know that exactly how?? And since the original question
was obviously some kind of test material, do you presume that
you know the intention of the original test author as well??

Now compile it and it will print "55".

Several people corrected you on that already but you did not appear
to listen. "55" is, at best, the most -common- result of the
program. If the program were run on an EBCDIC system, the result
would be quite different. And in saying that it will print "55"
you missed the newline...
 

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

Forum statistics

Threads
474,166
Messages
2,570,907
Members
47,446
Latest member
Pycoder

Latest Threads

Top