Hi there,
I have to write simple programm and test what heppens when I incorrectly identify types for output.
for example:
main(){
int a=5;
printf("value is %f",a);
}
outcome of the print statement is 0.000000 instead of 5. why?
- if use %d instead of %f
outcome of the print statement is -1610612736 instead of 5.567, why?
- if use %c instead of %d
outcome of the print statement is (sign) instead of 5. why?
-if use %d instead of %c
outcome of the print statement is 97 instead of "a". why?
- if use % instead of %s
outcome of the print statement is 2686746 instead of "Sean". why?
- if use %s instead of %d
the program stop working.
I know all types have a different lenght and location but would to know why the computer interpretation is wrong.
Thank you very much for help