0

z value is 5 in main function,but after calling fun function z value become 15 in fun function.can anyone syggest the answer....

#include <stdio.h> int fun(int a,int b,int c) { printf("the value of x... %d\n",a); printf("the value of y..... %d\n",b); printf("the value of z..... %d\n",c); return 2*(a+b+c); } int main() { int x=1,y=2,z=3,result; result=fun(x,y,(z=5,z+10)); printf("the value of x... in main%d\n",x); printf("the value of y.....in main %d\n",y); printf("the value of z...in main %d\n",z); printf("%d",result); }

22nd Feb 2018, 8:35 PM
Anand Namastemath
Anand Namastemath - avatar
1 Answer
+ 4
You used comma operator whig take the last instruction as its value, here z + 10
23rd Feb 2018, 9:07 PM
Baptiste E. Prunier
Baptiste E. Prunier - avatar