main()
{
           int a;
           a=message();
}
message()
{
          printf("\n C language");
}

//what is the output and what return will return to a";

Fbody commented: Major fail, rezzing a 2.5 year dead thread with an irrelevant post that has no [code] tags and won't even work. +0

Recommended Answers

All 3 Replies

start quote:

main()
{
           int a;
           a=message();
}
message()
{
          printf("\n C language");
}

what is the output and what return will return to a;

Since this is the C++ forum there would be no output from that since C++ does not support implicit types on functions or calling functions without a prototype so the code will not compile.

Assuming that you meant to compile it as C and that you are willing to ignore the warnings produced rather than fix them then the output of the code is either undefined behaviour or extremely platform defined.

commented: Another 3 year resurrection... +11

Why not compile and run it to see the output yourself? Why not also modify the code to output the value of the variable "a" to see what is returned by the message() function, or debug to see what is there during runtime?

If you can't figure it out in your head, your best bet is to put it into practice and see what happens, i.e. run it.

Hint: The return value to a is undefined because the function doesn't explicitly return a value. Also, most modern compilers will produce errors on that code.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.