Quiz #5

(Last Mod: 27 November 2010 21:38:40 )

ECE-1021 Home


Name:                                                             CODE:                 Section:           Date:                  

NO CALCULATORS MAY BY USED ON THIS QUIZ

int PutV_u(unsigned int n)

{

    unsigned int m;

    int i;

    int c;

 

    /* Determine how many digits there are */

    for (m = 1; n/m >= 10; m*=10 )

        /* EMPTY LOOP */;

 

    /* Print out the digits one-by-one */

    c = 0;

    do

    {

        for(i = 0; n >= m; i++ )

            n = n - m;

        PutC((char)('0' + i));

        c++;

        m = m / 10;

    } while ( m >= 1 );

 

    return c;

}

n m i c  
312 1 0 0  
212 10 1 1  
112 100 2 2  
12 10 3 (1) 3 (ret)  
2 1 0    
1 0 1 (2)    
0   0    
    1    
    2 (3)    
         
         
         
  1. (3 pts) Fill in the above memory map when the input is      312     (given by instructor)

  2. What is the output for the above value?      312       

    Indicate the point in the memory map where each character is output by placing a circled number next to the last memory value that changed prior to the output - a 1 for the first output, 2 for the second output, and so on.

  3. What is the return value for the above value?      3