Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

A. Consider 1. #include <P18F458.h> 2. void main(void) 3. { 4. unsigned char myn

ID: 1846032 • Letter: A

Question

A.     Consider

1.      #include <P18F458.h>   

2.      void main(void)

3.      {

4.      unsigned char mynum[]= "012345ABCD";

5.      unsigned char z;

6.      TRISB = 0;                                          

7.      for(z=0;z<10;z++)

8.      PORTB = mynum[z];

9.      while(1);                                            

10.   }

(a)    In the original code, what is sent to PORTB when z = 9?

(b)   If line 4 is changed to unsigned char mynum[]= "012345AB"; what is sent to PORTB when z = 9?

(c)    If line 4 is changed to unsigned char mynum[]= "012345ABCDEFGH"; what is sent to PORTB when z = 9?

(d)    How can you change line 7 the for loop so that it can read the whole mynum[] array whether it is "012345ABCD", "012345AB", "012345ABCDEFGH", or "012345ABCDEFGHIJKLMNOPQRSTUVWXYZ"?

Explanation / Answer

(A) the ascii value of D i.e. 68 is sent to PORTB


B) some garbage value is sent to PORTB


C) the ascii value of D i.e. 68 is sent to PORTB


D) for(z=0;mynum[z]!='';z++)

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote