#include <stdio.h>
void main()
{
double i, sale[5] = {157, 209, 251, 312, 500};
for (i = 0; i < 5; i++) {
printf("\n address:%u sale[%d]=%d", &sale[i], i, sale[i]);
}
}
This...
I want to put it this way.
I want to check the logical and physical order of the real numbers float and double.
What should I change to pick a mistake in that code?
array float double
#include <stdio.h>
int main(){
int i;
double sale[5] = {157, 209, 251, 312, 500};
for (i = 0; i < 5; i++) {
printf("\n address:%u sale[%d]=%f", &sale[i], i, sale[i]);
}
return 0;
}
The format string %d in the printf function represents an integer. If you change it to %f, it'll come out well.
Looking at the values of -99, -47, etc., it seems that the overflow is coming out because it has changed to the byte type. I don't know why this part turned into bye.
© 2024 OneMinuteCode. All rights reserved.