#include "avr/io.h"
main()
{
unsigned char= z ;
for(z=0;z<200;z++)
PORTA=z; //PORTA dispalys the value of z
}
Please explain the working of the loop as z is char and is acting as int
#include "avr/io.h"
main()
{
unsigned char= z ;
for(z=0;z<200;z++)
PORTA=z; //PORTA dispalys the value of z
}
Please explain the working of the loop as z is char and is acting as int
char
(and by extension, unsigned char
) is an integral type. An unsigned char
can hold values from 0 to 255.
Characters are typically stored in char
variables as well. What they actually store is the ASCII value of the character in question. For example:
char c = 'A';
The variable c
contains the value 65, which is the ASCII value of A
.
In the case of this code, an unsigned char
variable is being used in an integer context.