C Programming - Functions - Discussion
Discussion Forum : Functions - Find Output of Program (Q.No. 20)
20.
What will be the output of the program?
#include<stdio.h>
int fun(int);
int main()
{
float k=3;
fun(k=fun(fun(k)));
printf("%f\n", k);
return 0;
}
int fun(int i)
{
i++;
return i;
}
Discussion:
21 comments Page 2 of 3.
Jagan mohan reddy said:
1 decade ago
In main function fun (fun (n). So 2 times, so value incremented by 2 times, value is 5.0000.
Shivani said:
5 years ago
Here is fun( k=fun(fun)).
So, k = 2 times increment ie 5.
It will be 6 if k=fun(fun(fun))).
So, k = 2 times increment ie 5.
It will be 6 if k=fun(fun(fun))).
TUSHAR said:
9 years ago
@skp.
Yes, it is possible to convert float to int by type casting.
Yes, it is possible to convert float to int by type casting.
Rutul said:
8 years ago
In C, no function overloading concept so it shows error.
Udaysiri said:
1 decade ago
fun(k=fun(fun(k))) if two times increment answer is 5
Ranga teja said:
1 decade ago
An excellent explanation by ankit. Thank you.
Skp said:
10 years ago
Is it possible to convert float to int?
Manjubharathi said:
9 years ago
Thanks for explanation. Now I get it.
Dharmvir Kumar said:
1 decade ago
Pls again explain me this program?
Preethi said:
1 decade ago
Can anyone explain me this program?
Post your comments here:
Quick links
Quantitative Aptitude
Verbal (English)
Reasoning
Programming
Interview
Placement Papers