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.
Udhaya said:
8 years ago
#include<stdio.h>
int main()
{
extern int fun(float);
float a;
a = fun(3.14);
printf("%d\n", a);
return 0;
}
int fun(float a)
{
return (int)++a;
}
This give output '0'.
int main()
{
extern int fun(float);
float a;
a = fun(3.14);
printf("%d\n", a);
return 0;
}
int fun(float a)
{
return (int)++a;
}
This give output '0'.
(4)
Lakshmi said:
7 years ago
Why ++aa?
It can be ++a.
It can be ++a.
(1)
Suraj said:
8 years ago
After passing the argument to the function need its type of float than in the function it increment the value of a then you get the answer 4.
(1)
Dnyanu said:
9 years ago
Thank you all for the explanation.
(1)
Rohan said:
9 years ago
extern int fun(float).
In this statement "extern" also there. So that's means the memory of this function allocated in some other program. So this is one of the error.
In this statement "extern" also there. So that's means the memory of this function allocated in some other program. So this is one of the error.
(1)
Ssindham said:
9 years ago
Great discussion.
Thanks @Suman, Amlan Karmakar, @Neha, @Rekha @Nishanth.
Thanks @Suman, Amlan Karmakar, @Neha, @Rekha @Nishanth.
Sri said:
1 decade ago
Can any one explain this program? I can't understand.
Trisha said:
1 decade ago
What is that 2nd error? I didn't get that point. Can you please explain?
Abinaya said:
10 years ago
I too don't understand the 2nd error. Please explain me.
Pooja said:
10 years ago
Error: Previous declaration of 'fun' was here.
Can anybody explain me the meaning of the above error?
Can anybody explain me the meaning of the above error?
Post your comments here:
Quick links
Quantitative Aptitude
Verbal (English)
Reasoning
Programming
Interview
Placement Papers