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;
}
Garbage value
0 (Zero)
1990
No output
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 5 of 5.

Rakesh said:   1 decade ago
But the function doesnt have any return value / statement so how could this be possible according to me there must be a garbage value can give a fulfledged explanation if this ques?

Amit said:   1 decade ago
Accumulator is a place where the results are stored after calculation.

Amit said:   1 decade ago
What is accumulator?


Post your comments here:

Your comments will be displayed after verification.