Adobe Interview Question for Member Technical Staffs


Country: India
Interview Type: In-Person




Comment hidden because of low score. Click to expand.
11
of 11 vote

This was my answer. He was satisfied with this.

int convert(int x)
{
     int c = n;
     c = c << 8 | n;
     c = c << 16 | c;
     return c;
}

- Nitin Gupta November 03, 2012 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

can you please explain how your code works.
that is how << and | works.

- chan November 04, 2012 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 votes

wht abt this code??

int p;
printf("enter any hex number");
scanf("%x",&p);
int q;
int r;
q=p;
r=q<<8;
p=p|r;
r=q<<16;
p=p|r;
r=q<<24;
p=p|r;

printf("0X %x",p);

- Ankur November 16, 2012 | Flag
Comment hidden because of low score. Click to expand.
-2
of 2 votes

I don't understand why you get 8 votes, I would give you -1 if I have time.

int converint(int a)
{
return a<<24|a<<16|a<<8|a;
}

- Anonymous December 25, 2013 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 votes

@Downvote.if.I.had.time.Anonymous:

He first computes 0x2525 and then shifts that and ORs that. Yes, there is a typo of using n instead of x, but we can give him that.

But your solution is more readable, and quite possibly more efficient (inspite of the extra bit shift and bitwise or as compared to the +8 solution), as the compiler can work with registers only and not deal with any locals.

- Anonymous December 25, 2013 | Flag
Comment hidden because of low score. Click to expand.
2
of 2 vote

Corrected version

int convert(int x)
{
     int c = x;
     c = c << 8 | c;
     c = c << 16 | c;
     return c;
}

- mandeep singh November 06, 2012 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

Could you explain how it works??

- Anony November 15, 2012 | Flag
Comment hidden because of low score. Click to expand.
-1
of 1 vote

Correct Me if I m Wrong :

int convert(int x)
{
int c = x;
c = c << 8 | c;
c = c << 8 | c; // Rather Than c = c << 16 | c;
return c;
}

- Anonym November 22, 2012 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 votes

1). c = 0x25
after right shift 8 bit
c = 0x2500
now OR with x
c = 0x2525
similarly for next shift

- jainrajrahul December 04, 2012 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 vote

int convert(int n)
{
retrun (0x01010101 * n);
}

- Anonymous November 14, 2012 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

This is fine but can some body write a good tutorial on this concept ? I want to understand this concept thoroughly..

Plz if some one can or give pointer from where I can study this.

- Sapna November 17, 2012 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 vote

Int32 X = 0x25;
Int32 Y = 0;
for (int i = 0; i < 4; i++)
{
Y = ((Y << 8) | X);
}

- nishshah January 24, 2013 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

Int32 X = 0x25;
Int32 Y = 0;
for (int i = 0; i < 4; i++)
{
Y = ((Y << 8) | X);
}
return Y;

- nishshah January 24, 2013 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

res |= (num << 16)|(num << 8);

- Anonymous January 24, 2013 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

res |= (num << 16)|(num << 8);

- Anonymous January 24, 2013 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

Assuming 32-bit

int b =0x25; // any hex number
b = b+((b & 0xffff) << 8);
b = b+((b & 0xffff) << 16);

- Goutam February 12, 2013 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

after using left shift operator by 8(0x25<<8),only last 8 bit information will still there(0x00) not any 16 bit information like(0x2500).

- neha April 15, 2013 | Flag Reply
Comment hidden because of low score. Click to expand.
-1
of 1 vote

@Neha: You are wrong. Integer is of 4 bytes. So it can hold upto 32 bit info.

- Nitin Gupta April 15, 2013 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 vote

#include<stdio.h>
void main()
{
    int num = 0x25,i;
    for(i=0;i<4;i++)
    {
        num = num << 8 | num;
    }
    printf("%X",num);
}

- Amit Khatri August 10, 2013 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

convert x int to decima it will give 37 multiply it with 623191333 it will give a number whose hexadecimal form will be y.

- Anonymous April 05, 2014 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

main()
{

    int i;
    int count;
    long y;
    while(1)
    {
        y=0;
        count=0;
        printf("Input and number :");
        scanf("%u", &i);
        printf("You entered %d (0x%x)\n", i,i);

        if(i>255)
        {
            printf("enter number less that 256\n");
            continue;
        }


        while(count++!=sizeof(y))
        {
            printf(".");
            y = (y<<8)|i;
        }

        printf("\nOutput %ld (0x%lx)\n", y,y);
    }

- Satish June 03, 2015 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

main()
{

    int i;
    int count;
    long y;
    while(1)
    {
        y=0;
        count=0;
        printf("Input and number :");
        scanf("%u", &i);
        printf("You entered %d (0x%x)\n", i,i);

        if(i>255)
        {
            printf("enter number less that 256\n");
            continue;
        }


        while(count++!=sizeof(y))
        {
            printf(".");
            y = (y<<8)|i;
        }

        printf("\nOutput %ld (0x%lx)\n", y,y);
    }

- Satish June 03, 2015 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

#include<stdio.h>
void main()
{
int num = 0x25,i;
char *ch;
ch = (char *)&num;
printf("%X\n",num);
for(i=0;i<4;i++)
{
*ch=num;
printf("%X\n",*ch);
ch=ch+1;

}
printf("%X\n",num);

}

- Anonymous December 18, 2016 | Flag Reply
Comment hidden because of low score. Click to expand.
-1
of 1 vote

#include <stdio.h>

int main() {
int x = 0x25;
int i, y = x;

for (i = 0; i < 4; i++) {
y = y | (y << 8);
}
printf("y = %#x ", y );

return 0;
}

- unknownMind November 20, 2012 | Flag Reply
Comment hidden because of low score. Click to expand.
-2
of 2 vote

what if I do it like this :)
int convert(int x) {
x=0x25252525;
return x;
}

- Qamar December 06, 2012 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

This question is either incomplete or wrong. every approach is wrong you cant convert one constant to another constant.
if you ask to convert a number into another then there would be infinite number of ways of doing that. like convert 5 into 10
you can say 5+5=10, 5x2=10, 5+20-15=10.

- anonymous December 12, 2012 | Flag


Add a Comment
Name:

Writing Code? Surround your code with {{{ and }}} to preserve whitespace.

Books

is a comprehensive book on getting a job at a top tech company, while focuses on dev interviews and does this for PMs.

Learn More

Videos

CareerCup's interview videos give you a real-life look at technical interviews. In these unscripted videos, watch how other candidates handle tough questions and how the interviewer thinks about their performance.

Learn More

Resume Review

Most engineers make critical mistakes on their resumes -- we can fix your resume with our custom resume review service. And, we use fellow engineers as our resume reviewers, so you can be sure that we "get" what you're saying.

Learn More

Mock Interviews

Our Mock Interviews will be conducted "in character" just like a real interview, and can focus on whatever topics you want. All our interviewers have worked for Microsoft, Google or Amazon, you know you'll get a true-to-life experience.

Learn More