Interview Question 3573

Created by admin on Sat, 17/11/2012 - 12:40
Explanation: 
Error is in line with statement a++. The operand must be an lvalue and may be of any of scalar type for the any operator, array name only when subscripted is an lvalue. Simply array name is a non-modifiable lvalue..
Question: 

main( )
{
int a[ ] = {10,20,30,40,50},j,*p;
for(j=0; j<5; j++)
{
printf(“%d” ,*a); a++; } p = a; for(j=0; j<5; j++)
{
printf(“%d ” ,*p); p++;
}
}

Language: 
Answer: 

Compiler error: lvalue required.