Page 62 - Programming Microcontrollers in C
P. 62
Program Flow and Control 47
na=na+1;
}
else if(c==’E’ || c==’e’)
{
ne=ne+1;
}
else if(c==’I’ || c==’i’)
{
ni=ni+1;
}
else if(c==’O’ || c==’o’)
{
no=no+1;
}
else if(c==’U’ || c==’u’)
{
nu=nu+1;
}
else
{
nother=nother+1;
}
}
This block of source code is longer than the original form, but it
is exactly the same to the compiler. This code is indeed longer than
the original form, but it is also much less open to misinterpretation
and misunderstanding. Writing code that cannot be misinterpreted is
as much the responsibility of the programmer as writing code that
works. Therefore, when writing production code, you should seri
ously aim to generate code that is not open to any misinterpretation,
even though it will make your source code somewhat longer. Usu
ally when you write code that is easy to maintain, it will not affect
the size of your object code.
The printf function call
printf(“As=%d, Es=%d, Is=%d, Os=%d, Us=%d and”
“ Others=%d\n”,na,ne,ni,no,nu,nother);