Science, asked by tanvi9399400, 2 months ago

what is type compatibility??
Thankyou so much sis❤️!!

Attachments:

Answers

Answered by Anonymous
4

 \huge \bold  \red{welcome....}

Type Compatibility

C++ is very strict with regard to type compatibility as compared to C. Type compatibility is very close to automatic or implicit type conversion. The type compatibility is being able to use two types together without modification and being able to subsititute one for the other without modification.

The type compatibility is categorized into following three types by the compiler:

Assignment compatibility

In assignment compatibility,if the type of variable assigned to another variable is different it results into loss of value of assigned variable if the size of assigned variable is large than the size of variable to which it is assigned.

For example

float n1=12.5;

int n2=n1;

This assigning of float value to int type will result in loss of decimal value of n1. However, this type compatibility will not show any error but it might give a warning “possible loss of data”.

Expression compatibility

Consider following example

int n=3/2;

cout<<n;

Here the result will be 1. The actual result of 3/2 is 1.5 but because of incompatibility there will be loss of decimal value

Parameter compatibility

Due to incompatibility in type of actual parameter and formal parameters loss of data occurs.

For example

void show(int n)

{cout<<”n=”<<n;}

void main()

{show(8.2);}

Here output will be n=8 due to incompatibility in actual and formal parameter type.

And Thanks u too ❤❤

Answered by Maseerah
1

Answer:

The type compatibility is being able to use two types together without modification and being able to subsititute one for the other without modification. The type compatibility is categorized into following three types by the compiler: Assignment compatibility.

Explanation:

This is correct.

Hope its helps you.

Please mark me as Brainliest

Similar questions