Can any one explain me the output of the following program?
Code:#include<studio.h> #define foo(x,y) x+y into foo(int x,int y); main(){ Print("%d",foo(5,3)); } into foo(into x, int y) { return x*y; }
Can any one explain me the output of the following program?
Code:#include<studio.h> #define foo(x,y) x+y into foo(int x,int y); main(){ Print("%d",foo(5,3)); } into foo(into x, int y) { return x*y; }
The output will be nothing since it doesn't compile due to multiple errors/typos/brainos.
The Canada man is right! However, the indentation is also something you should take in great consideration.
Let's try to debug a bit.
Give it another shot.Code:#include<studio.h> <-- It's stdio.h. It is composed from standard and input-output #define foo(x,y) x+y <-- I do not see the reason of existence of this into foo(int x,int y); <-- It is int, not into! main() <-- We use to write int main(void) { Print("%d",foo(5,3)); <-- It is printf, not print /* Here we use to write return 0, in order to show that the code executed as we planed to. */ } into foo(into x, int y) <-- It is int, not into! { return x*y; }
Code - functions and small libraries I use
It’s 2014 and I still use printf() for debugging.
"Programs must be written for people to read, and only incidentally for machines to execute. " —Harold Abelson
Correct all the typos and other faults (you already got suggestion for those), compile and run. Then you know what will be the output…
The next step would probably be to figure out why…
I suspect that the #define thing could mess things up for the compiler, though…
Tried to correct the code myself and compile it, and as long as the #define is there, gcc refuse to compile it. Why? Probably, to begin with, because the line ”int foo(int x, int y)” will be replaced with something like ”int int x+int y” by the pre-compiler, and that doesn't make much sense to me at least…
you guys probably just gave the OP all the answers to this homework assignment.
What can this strange device be?
When I touch it, it gives forth a sound
It's got wires that vibrate and give music
What can this thing be that I found?
this is definitely a homework question.
You've no idea how often we get a thread with literally this exact title.
Personally I've learnt to ignore them. Ask a compiler the answer instead.
My homepage
Advice: Take only as directed - If symptoms persist, please see your debugger
Linus Torvalds: "But it clearly is the only right way. The fact that everybody else does it some other way only means that they are wrong"
I ran the following program and did not get the result I expected.
I thought that the output should be [GUESS], but instead it's printing [RESULT]. The reason I think it should be [GUESS] is because [the reasoning you used to arrive at your guess, by thinking about the problem before asking the question on a forum]. Can someone explain why this might be wrong?Code:/* This is where you put the actual code that you compiled, making sure correct spelling and syntax are observed. Also ensure the code is indented properly! */
^^ You still probably won't get a direct answer when posting like this, but people are more likely to take your problem seriously and offer helpful advice that will lead you to the answer you're looking for.