void main(){
int a = 5;
int b = a/2;
int c = b*2;
printf("integer truncation error in C\n");
printf("the value of a is %d\n",a);
printf("the value of b = a\\2 is %d\n",b);
printf("the value of c = b*2 is %d\n",c);
getch();
}
and the output is

which displays the result of (5/2)*2 = 4 which is wrong.
No comments:
Post a Comment