ExamVeda
Login
Home
This question belongs to C Program Pointer
Pointer
?

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);
}

Answer & Solution
Correct Answer: Option C
Let's discuss the solution. Join the discussion
Examveda
Question posted by Examveda
Community

Join the Discussion

11 Comments
Dayan Bhoi
Dayan Bhoi 5 years ago
Sabb ka galat hai bc
Abdulrhman Alyafai
Abdulrhman Alyafai 6 years ago
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");

}
Abhay Chhetri
Abhay Chhetri 6 years ago
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.
Srav Shivkumar
Srav Shivkumar 8 years ago
when i execute this pgm i get an error stating main should return int.how is this showing 0.000? some pls explain
PRADEEPCHIN2
PRADEEPCHIN2 9 years ago
can anyone please explain this program.
Mayur Patil
Mayur Patil 9 years ago
i cannot understand this typecast
and output=0.000000
SAKSHI MISHRA
SAKSHI MISHRA 9 years ago
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.
Ashish Munot
Ashish Munot 9 years ago
hey how it is possible
Ritanshi Jain
Ritanshi Jain 9 years ago
Can anyone plzz explain how is this answer correct
Komal Jha
Komal Jha 9 years ago
How did the answer came 0.000
Akash Algikar
Akash Algikar 11 years ago
What is the solution anyone??