Re: [algogeeks] C prog o/p

2012-10-13 Thread Ashok Varma
(int *)60 => 60 is treated as address and 60 = 0x3c similarly 71 = 0x47 On Sun, Oct 14, 2012 at 11:18 AM, bharat b wrote: > @Ashok : I didn't get this answer .. > i=0x3c --> what is this address .. variables has addresses but not the > values right? we are not storing 60 any where right? > 0x11 =

Re: [algogeeks] C prog o/p

2012-10-13 Thread bharat b
@Ashok : I didn't get this answer .. i=0x3c --> what is this address .. variables has addresses but not the values right? we are not storing 60 any where right? 0x11 = 3 in decimal format not 11 base 10. typecasting to (int*) needs an address right? I mean int b=10; int * a=(int*)&b; On Sat, Oc

Re: [algogeeks] Re: can we check a number has last digit 5 or not using bitwise operator.

2012-10-13 Thread Dave
@Piyush: I think not. Try n = 17 = 4*4 + 1 or n = 19 = 4*4 + 3. But you can say that n = 4 * a + b, with 0 <= b <= 3, is a multiple of 5 if and only if a - b is a multiple of 5, thus reducing to a simpler problem. That's the basis of the solution I posted earlier in this string. Dave On Satur

Re: [algogeeks] Re: can we check a number has last digit 5 or not using bitwise operator.

2012-10-13 Thread Piyush Grover
forgot to assign: m = n; On Sun, Oct 14, 2012 at 2:27 AM, Piyush Grover wrote: > The number which has 5 as last digit can be written as > n = 4*a + b where b = 1 or 3 > so if 4*a + 1 == n or 4*a + 3 == n; then n has 5 as a last digit. > So code looks like: > > void main() > { > int n, m; > scan

Re: [algogeeks] Re: can we check a number has last digit 5 or not using bitwise operator.

2012-10-13 Thread Piyush Grover
The number which has 5 as last digit can be written as n = 4*a + b where b = 1 or 3 so if 4*a + 1 == n or 4*a + 3 == n; then n has 5 as a last digit. So code looks like: void main() { int n, m; scanf("%d", &n); m >>= 2; m <<= 2; if(add(m, 1) == n || add(m,3) == n) puts("yes"); else puts

Re: [algogeeks] Assembly Output ADOBE question

2012-10-13 Thread Sharad Dixit
This code could've been intended to calculate some non-negative integer power of another integer, but the whole stack thing with the order of pushes and pops is weird. There are no such registers and instructions. What is it ?? cheers On Sat, Oct 13, 2012 at 6:10 PM, Ashok Varma wrote: > what

Re: [algogeeks] C prog o/p

2012-10-13 Thread Ashok Varma
This gives a clear explanation: #include main(){ int *i,*j; i=(int*)60; j=(int*)71; printf ("%p %p %d",i,j,j-i);} op: 0x3c 0x47 2 0x47 - 0x3c = 0x11 and hence j-1 = 2 (11/4 = 2, size of int = 4 bytes) On Sat, Oct 13, 20

Re: [algogeeks] Assembly Output ADOBE question

2012-10-13 Thread Ashok Varma
what does the stack initially hold ? On Sat, Oct 13, 2012 at 4:18 PM, Akshat Sapra wrote: > > DETERMINE THE OUTPUT R1,R2,R3 ARE THREE REGISTERS > > START :POP R1 > POP R2 > COMPARE R2,0 > JUMP_EQ DONE_Z > PUSH R2 > PUSH R1 > SUBTRATCT R2,1 > PUSH R2 > CALL START > POP R3 > POP R1 > POP R2 > MULT

[algogeeks] C prog o/p

2012-10-13 Thread bharat b
#include main() { int *i,*j; i=(int*)60; j=(int*)71; printf("%d",j-i); } -- You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algog