16) What is a pragma?
#ifdef SAMPLE /* Checking if SAMPLE is defined */ #undef SAMPLE /* If so, then reset it */ #endif #define SAMPLE 0 /* Then redefine with intended value */
18) What is an lvalue?
An lvalue is an expression to which a value can be assigned. The lvalue expression is the one which is located on the left side a statement, whereas an rvalue is located on the right side of a statement. Each assignment must have a valid lvalue and rvalue. The lvalue expression must refer to a storage where something can be stored. It can't be a constant.
19) How to assign one array to another?
You can't assign an array to other. Arrays are not lvalue, because they don't refer to one variable, rather a set of variables. So they can't be placed on the left hand side of an assignment statement. For example the following statement will generate compilation error.
int x, y; x = y;
20) what is the order of operator precedence, left to right or right to left ?
None of them is standard. C does not always start evaluating left to right or right to left. Normally, function calls are done first, followed by complex expressions and then simple expressions. That is why it is best to use parenthesis in all expressions, without depending on precedence.
21) What is the difference between ++X and X++?
The ++ operator is called the incremental operator. When the operator is placed before, the variable is incremented by 1 before it is used in the statement. When the operator is placed after the variable, then the expression is evaluated first and then the variable is incremented by 1.
22) What happens when we use incremental operator in a pointer?
It depends upon the type of the pointer. It gets incremented by the size of the data type, the pointer is pointing to. For example
char p; p++; /* here p increments by 1*/ int p; p++;/* here p increments by 4(for 32 bit system)*/
23) What will be output of the following code snippet?
int num1=5; int num2=5; num1 =num1++ + num1--; num2 =++num2 + --num2; printf("num1=%d num2=%d",num1,num2);
Output will be num1=10 num2=10.
24) Can the sizeof operator be used to tell the size of an array passed to a function?
No. The sizeof() operator can't tell the size of an array, because it is actually a pointer to the data type of the array.
25) Can you change the value of an array tag?
No. An array tag can't be used as a storage, because it is not an Lvalue. It can be thought as a pointer to the datatype of the array which is constant and which can't be changed or assigned dynamically.