C Programming - Functions - Discussion
Discussion Forum : Functions - Find Output of Program (Q.No. 1)
1.
What will be the output of the program in 16 bit platform (Turbo C under DOS)?
#include<stdio.h>
int main()
{
int fun();
int i;
i = fun();
printf("%d\n", i);
return 0;
}
int fun()
{
_AX = 1990;
}
Answer: Option
Explanation:
Turbo C (Windows): The return value of the function is taken from the Accumulator _AX=1990.
But it may not work as expected in GCC compiler (Linux).
Discussion:
43 comments Page 4 of 5.
Rathika.B said:
1 decade ago
What is _AX, same type of similar models & their explanations?
KinG said:
1 decade ago
In C, _AX Denotes the Accumulator Where the result of Airthmatic & Logical Operation is stored.
NRB said:
1 decade ago
How compiler knows _AX is accumulator and there is no return value to calling function. As explained above there is no need get the any value from outside functions. So it is clear for particular code and if same program will run in GCC compiler I got output 1. Please explain clearly. Thanks in advance.
Amit said:
1 decade ago
What is accumulator?
Ganesh said:
1 decade ago
sir _ax variable is not declared in function how can it executes
Jayanthi said:
1 decade ago
What is the difference between return; and return 0; and also return();?
Where to use void main(), int main() and main()?
Where to use void main(), int main() and main()?
Tanishka said:
1 decade ago
void main() is used when we dont have to return value because void is a return type and it does not return any value.
int main() is used when we want to return any value this will return integer type value by the os.
You can also use float before main() function if you do so it returns float type value.
int main() is used when we want to return any value this will return integer type value by the os.
You can also use float before main() function if you do so it returns float type value.
Deepak said:
1 decade ago
Can a function be declared inside another function?
ADDY said:
1 decade ago
@Deepak.
Yes a function can be defined another function.
Yes a function can be defined another function.
Nitish anand said:
1 decade ago
There should be a return type in the function and is it possible to declare a function inside the main function. As per me during compilation when function is encountered in the main then compiler will have no information of the function at that time. So it will give compile error.
Post your comments here:
Quick links
Quantitative Aptitude
Verbal (English)
Reasoning
Programming
Interview
Placement Papers