Your format specifiers in the printf statements are not right.
Also integers and floats are stored differently internally. Also, you have
to explicitly cast float into int as automatic conversion is not applicable
here in printf.

I hope this code helps your cause ,

#include<stdio.h>

int main()
{
    float a[]={13.24,1.5,1.5,5.4,3.5};
    float *j;
    j=a;
    j=j+4;
    printf("\n%p,%f,%f",j,*j,a[4]);

    float p=3.5;
    printf("\n%f,%d",p,(int)p);

    p=4.5;
    printf("\n%d,%f",(int)p,p);

}






On Sat, Jun 4, 2011 at 2:21 PM, himanshi narang <[email protected]
> wrote:

> #include<stdio.h>
>
> int main()
> {
>     float a[]={13.24,1.5,1.5,5.4,3.5};
>     float *j;
>     j=a;
>     j=j+4;
>     printf("\n%d,%d,%d",j,*j,a[4]);
>
>     float p=3.5;
>     printf("\n%f,%d",p,p);
>
>     p=4.5;
>     printf("\n%d,%f",p,p);
>
> }
>
>
> output----
> -1080027596,0,1074528256
> 3.500000,0
> 0,0.000000
>
> plzz explain y i m getting dis output......
>
> --
> You received this message because you are subscribed to the Google Groups
> "Algorithm Geeks" group.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to
> [email protected].
> For more options, visit this group at
> http://groups.google.com/group/algogeeks?hl=en.
>



-- 
Rohit Sindhu

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.

Reply via email to