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;
}
Answer: Option
Explanation:
2 Errors
1. Type mismatch in redeclaration of fun
2. Type mismatch in parameter aa
1. Type mismatch in redeclaration of fun
2. Type mismatch in parameter aa
Discussion:
35 comments Page 1 of 4.
Shan said:
2 decades ago
Linker Error:undefined symbof fun(float)
Priyanka Gupta said:
1 decade ago
In this where type mismatch in redeclaration of function fun.
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
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.
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?
Priyanka said:
1 decade ago
When extern int fun(float) is declared in main(), the compiler search for its defination in the program. But it found a function int fun(int aa) which differ from what is declared in main(),& it treated it as another function.
So compiler is unable to find the defination for int fun(float)
function & thus the error comes.
So compiler is unable to find the defination for int fun(float)
function & thus the error comes.
Post your comments here:
Quick links
Quantitative Aptitude
Verbal (English)
Reasoning
Programming
Interview
Placement Papers