1)
Answer:
H
Explanation:
* is a dereference operator & is a reference operator. They can be applied
any number of times provided it is meaningful. Here p points to the first
character in the string "Hello". *p dereferences it and so its value is H. Again
& references it to an address and * dereferences it to the value H.
2)
Answer:
Compiler error: Undefined label 'here' in function main
Explanation:
Labels have functions scope, in other words the scope of the labels is limited
to functions. The label 'here' is available in function fun() Hence it is not
visible in function main.
3)
Answer:
Compiler error: Lvalue required in function main
Explanation:
Array names are pointer constants. So it cannot be modified.
4)
Answer:
Output Cannot be predicted exactly.
Explanation:
Side effects are involved in the evaluation of i
5)
Answer:
Compiler Error
Explanation:
The expression i+++++i is parsed as i ++ ++ + i which is an illegal
combination of operators.
main(){ char *p; p="Hello"; printf("%c\n",*&*p); }
Answer:
H
Explanation:
* is a dereference operator & is a reference operator. They can be applied
any number of times provided it is meaningful. Here p points to the first
character in the string "Hello". *p dereferences it and so its value is H. Again
& references it to an address and * dereferences it to the value H.
2)
main() { int i=1; while (i<=5) { printf("%d",i); if (i>2) goto here; i++; } } fun() { here: printf("PP"); }
Answer:
Compiler error: Undefined label 'here' in function main
Explanation:
Labels have functions scope, in other words the scope of the labels is limited
to functions. The label 'here' is available in function fun() Hence it is not
visible in function main.
3)
main() { static char names[5][20]={"pascal","ada","cobol","fortran","perl"}; int i; char *t; t=names[3]; names[3]=names[4]; names[4]=t; for (i=0;i<=4;i++) printf("%s",names[i]); }
Answer:
Compiler error: Lvalue required in function main
Explanation:
Array names are pointer constants. So it cannot be modified.
4)
void main() { int i=5; printf("%d",i++ + ++i); }
Answer:
Output Cannot be predicted exactly.
Explanation:
Side effects are involved in the evaluation of i
5)
void main() { int i=5; printf("%d",i+++++i); }
Answer:
Compiler Error
Explanation:
The expression i+++++i is parsed as i ++ ++ + i which is an illegal
combination of operators.