in Digital Logic retagged by
756 views
5 votes
5 votes

Consider the function:

int fun(int n)
{
    if (n==4)
        return n;
    else return 2*fun(n+1);
}


A MOD-16 ripple counter is holding the count $(1001)_2.$ What will be the count after "$(\text{fun}(2)+15)_{10}$" clock pulses?

  1. $(1000)_2$
  2. $(1010)_2$
  3. $(1011)_2$
  4. $(1101)_2$
in Digital Logic retagged by
756 views

2 Comments

function returns 31

then it would become (31+9)%16 = 9 (1001)
0
0

@Ruturaj Mohanty

Can u please ans this?

0
0

2 Answers

4 votes
4 votes
It is mod 16 so after 16 pulses it returns to 9

Then after 15 more pulses it will 1 step behind 9 that is 8 (1000)

3 Comments

not able to understand fun(2)+15 will return 31 then mod 16 because mod 16 counter then what happed i am not able to understand :(
0
0
You are right.It will return 31 and it is 31-st clock pulse.Since this is Mod 16 counter, the count 1001 or 9 repeats at clock pulse 32.

We need count at clock pulse 31 which is one count down from clock pulse 32.

9-1= 8 (or) 1000
2
2
Oh I see thanks
0
0
0 votes
0 votes
after solving, function returns 31

and now have to find out what will be count after 31 clock pulses more.

So, for that, first of all have to check current position of counter,

currently counter on 9, now 6 more pulses left to reach to 15 (as it’s MOD-16 so 0-15)

31-6= 25 , now current position 0 and 25 still left

25-16 = 9

so…..current position is 8 (as 0 there) which is 1000 !!!!
Answer:

Related questions