questions of c and answer

(q) What will be output of the following program?
void main()
{
long int a,b=5;;
~a=++b + ++b + ++b;
printf("%d  %d",++a,++b);
getch();
}
Output: error, L value required
Explanation:
After applying any operator in variable name it always give a value.
(Type): urinary type casting operator is not exception for this. It is similar to write
3456=5
It is invalid c statement. Because left side of assignment operator must be a variable not any constant.
(q) What will be output of the following program ?
void main()
{
int x;
int y;
x+y=10;
x=3;
printf("%d",y);
getch();
}
Output: error, L value required
Explanation:
After applying any operator in variable name it always give a value.
(Type): urinary type casting operator is not exception for this. It is similar to write
3456=5
It is invalid c statement. Because left side of assignment operator must be a variable not any constant.

No comments: