Volatile modifier keyword
questions in c programming language:
(q) What will be output of the
following program?
void main()
{
volatile a=5;
a=~a+ ++a;
clrscr();
printf("%d",a);
getch();
}
Output: -1
Explanation:
Volatile variable can be modifying by interrupt or other
process in preprocessor. So in normal output will not affect.
Note. ~ is one’s complement operator
(q) What will be output of the
following program?
void main()
{
volatile a=5;
a=~a+++a;
clrscr();
printf("%d",a);
getch();
}
Output: 0
Explanation:
Volatile variable can be modifying by interrupt or other
process in preprocessor. So in normal output will not affect.
a+++a means a++ + a.
Note. ~ is one’s complement operator.
No comments:
Post a Comment