C Programming and Technical

Q. What is automatic type promotion in c?

A. In c if two operands are of different data type in a binary operation then before performing any operation compiler will automatically convert the operand of lower data type to higher data type. This phenomenon is known as automatic type conversion.

For example:
int a=10,c;
float b=5.5f;
c=a+b;
Here a int variable while b is float variable. So before performing addition operation value of the variable a (Lower data type) will automatically convert into float constant (higher data type) then
it will perform addition operation.

Read Solution (Total 0)

C Other Question

Q. Tell any five properties of auto variables?
A. Auto variables are defined inside a function. A variable declared inside the function without storage class name is, by default, an auto variable. These functions are declared on the stack. The stack provides temporary storage
Q. What are differences between sizeof operator and strlen function?

A. sizeof is keyword of c which can find size of a string constant including null character but strlen is function which has been defined string.h and can find number of characters in a string excluding null character