What will be the output of the following program code?
#include<stdio.h>
void main()
{
int i = 10;
void *p = &i;
printf("%f", *(float *)p);
}
#include<stdio.h>
void main()
{
int i = 10;
void *p = &i;
printf("%f", *(float *)p);
}A. Error
B. 10
C. 0.000000
D. None of these.
Answer: Option C

Sabb ka galat hai bc
int id = 0;
try{
if (id == 0)
throw new RuntimeException(“id is zero ”);
} catch(RuntimeException e){
System.out.print(e.getMessage());
}
finally{
System.out.println("Close Program");
}
since the value that we are de referencing is integer type thus type casting in floating type will give the output 0.000. but if we will type cast in integer type then the output will be 10.
when i execute this pgm i get an error stating main should return int.how is this showing 0.000? some pls explain
can anyone please explain this program.
i cannot understand this typecast
and output=0.000000
We can de-reference a void pointer by typecasting it to any of float, int or char pointers. Here we are accessing the de-referenced value (int i=10) but since we are printing %f we get 0.00000.
hey how it is possible
Can anyone plzz explain how is this answer correct
How did the answer came 0.000
What is the solution anyone??