C Programming :: Variables & Data Types - Discussion
Home > C Programming > Variables & Data Types > MCQs Questions Discussion
24 / 51
What is the output of the following program?
#include<stdio.h>
void main()
{
int k=ret(sizeof(float));
printf("\n here value is %d",++k);
}
int ret(int ret)
{
ret += 2.5;
return(ret);
}
#include<stdio.h>
void main()
{
int k=ret(sizeof(float));
printf("\n here value is %d",++k);
}
int ret(int ret)
{
ret += 2.5;
return(ret);
}
AHere value is 6
BHere value is 5
CCompilation Error
DHere value is 7
Answer: Option (Login/Signup)
Show Explanation
Asked In ::
STEP-BY-STEP
We know that size of float is 4 bytes.
So, int k=ret(sizeof(float));
or, k=ret(4);
Now, in line 9-
ret=ret+2.5;
or, ret=4+2.5;
or, ret=6.5;
But, 'k' is of type 'int', hence, k=6.
In the next line, we are printing the value of ++k, i.e, 7.
Hence, the output is Here value is 7.
Read Full Answer
Report Error
Please Login First Click Here