in Programming in C
699 views
0 votes
0 votes
Please explain the output for the following program:

 

#include<stdio.h>

int main() {
    
    int i = 100;
    int *a = &i;
    float *f = (float *)a;
    
    (*f)++;
    
    printf("%d", *a); //getting some garbage value
}
in Programming in C
699 views

3 Comments

@garvit_vijai,

unknowingly, you took the toughest example... for understanding this you need the concept of how floating points represents in memory.

0
0
moved by
printf (" *f=%d ", *f);
gives 17?why?
0
0

make it as comment not as answer

the similar concept is https://gateoverflow.in/241739/nptel

 

0
0

Please log in or register to answer this question.

Related questions