needed solutions...

Write your question here.

int *iptr;
float num1=10.5;
iptr=&num1;

This above code is valid or not. If invalid.. Kindly explain why invalid??
It is invalid. You cannot and should not store address of float variable in pointer to integer. As you are not guaranteed that size of integer and float would match, to have some arbitrary implementation of floating point numbers or integral numbers, it is undefined behavior at best.
What's your guess for this question? From the other post you know that the first line means that iptr is a pointer to an integer type of variable.
My first pgm both variable int.. But other post iptr is integer type and num1 is float type. Why it is invalid??
MiiNiPaa gave you the answer :)


For this set to be valid the pointer would need to be defined to point to a float type variable.

float *iptr;
float num1=10.5;
iptr=&num1;
Because...
iptr is integer type and num1 is float type

Topic archived. No new replies allowed.