+1 vote
80 views

Find the number of tokens in the following C code$:$

main()
{
int x = 10 , *P ;
int y = x ++ ;
char * q ;
P = & x ; q = 'A' ;
if(*P>=10)
{
*P = x + 100;
}
else
{
printf("%d" , x);
/*comment*/
}

}


edited | 80 views

+1 vote

There $>=$   $(or)$   $\geq$ are only one token(because this is a operator in C language).

by Veteran (51k points)
selected
0

Is *P count to one token or two? My doubt is because it is a pointer variable..can you please tell about same for 'A' it is counted one not three.

+2
$*$ is the operator and $P$ are identifier so we count $*$P as two tokens.And for $'A'$, this is the character literal so we count as one token.

1
2