C Programming - Declarations and Initializations - Discussion

Discussion Forum : Declarations and Initializations - Find Output of Program (Q.No. 8)
8.
What is the output of the program
#include<stdio.h>
int main()
{
    extern int fun(float);
    int a;
    a = fun(3.14);
    printf("%d\n", a);
    return 0;
}
int fun(int aa)
{
	return (int)++aa;
}
3
3.14
4
Compile Error
Answer: Option
Explanation:
2 Errors
1. Type mismatch in redeclaration of fun
2. Type mismatch in parameter aa
Discussion:
35 comments Page 3 of 4.

Sundar said:   1 decade ago
In Turbo C it shows the following error:

Error PROGRAM.C 11: Type mismatch in redeclaration of 'fun'

In GCC (Linux) it shows the following errors:

Line 11: error: conflicting types for 'fun'
Line 4: error: previous declaration of 'fun' was here

Kavita.C.Karjagar said:   1 decade ago
Please write correct complete program because I want to compile.

Sundar said:   1 decade ago
A small correction required.

int fun(int aa) --> int fun(floatt aa)

It will display 4 as output.

Sushma said:   1 decade ago
What is actually "1. type mismatch in redeclaration of function" in this question?

Suresh said:   1 decade ago
This concept I cannot understand how is possible?

Palak agrawal said:   1 decade ago
How is possible? and what is floatt?

Hemanthkumar said:   1 decade ago
This word "mismatch" I am really fed up of this can any one explain?

Shan said:   2 decades ago
Linker Error:undefined symbof fun(float)

Suman said:   1 decade ago
Can anyone explain this statement: return (int)++aa in this program ?

Amlan Karmakar said:   1 decade ago
@Suman.

(int)++a means that float value of aa is type casted to int. It is called explicit conversion.


Post your comments here:

Your comments will be displayed after verification.