If we try to assign a variable with an incorrect value of datatype, then the compiler will (most probably) generate an error- the compile-time error. Or else, the compiler will convert this value automatically into the intended datatype of the available variable.
Example,#include
int main() {
// assignment of the incorrect value to the variable
int a = 20.397;
printf(“Value is %d”, a);
return 0;
}
The output generated here will be:
20
As you can already look at this output- the compiler of C will remove the part that is present after the decimal. It is because the data types are capable of storing only the whole numbers.