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 3 of 3.
Ankit said:
1 decade ago
fun(k=fun(fun(k)));
fun(k=fun(fun(3))); here fun(3)returns 4
fun(k=fun(4)); //here fun(4) returns 5
fun(k=5); //here 5 is assigned to k
& hence since it is float value it prints 5.000000
if statement was like this k=(fun(fun(fun(k))); k=6.000000
fun(k=fun(fun(3))); here fun(3)returns 4
fun(k=fun(4)); //here fun(4) returns 5
fun(k=5); //here 5 is assigned to k
& hence since it is float value it prints 5.000000
if statement was like this k=(fun(fun(fun(k))); k=6.000000
Post your comments here:
Quick links
Quantitative Aptitude
Verbal (English)
Reasoning
Programming
Interview
Placement Papers