Adobe Interview Question for Developer Program Engineers


Country: United States




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

does this meet the requirement?

int StrCompare(char* s1,char* s2)
{
	while(*s1 && *s1==*s2)
	{
		s1++;
		s2++;
	};
	if(!*s1 && !*s2)return 0;//equal
	if(*s1<*s2)return -1;     //s1<s2;
	else return 1;                //s1>s2
}

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

"does this meet"...

- G. Nazi. December 22, 2012 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 votes

hi G. Nazi..thanks for pointing out my mistake

- duckling December 23, 2012 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 votes

Can you please explain me the return statements.
It would be better, if you just explain me the entire program, emphasizing the part after while loops are over.

- Soumyadeep Biswas September 30, 2013 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 votes

1) what if S2==NULL?
2) what if we consider compare by int instead of byte
3) what if we consider int allignment
4)my code

int mystrcmp(const char* t, const char* s)
{

while((*t)&&(*s)&&((*t++-*s++)==0));
if((*t==0)&&(*s!=0))
return 1;
if((*t!=0)&&(*s==0))
return -1;
else
{
if(*(t-1)>*(s-1))
return 1;
if(*(t-1)<*(s-1))
return -1;
if(*(t-1)==*(s-1))
return 0;
}


}

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

#include<iostream>
using namespace std;
int string1 (char *a,char *b)
{
int flag=1;
for(;*a!='\0'||*b!='\0';)
{
if(*a!=*b)
{ flag=0;
break;
}
a++;
b++;
}
return flag;
}
int main()
{
int k;
char a[20],b[20];
cin>>a>>b;
k=string1(a,b);
if(k==0)
cout<<"No";
else
cout<<"Yes";

return 0;
}

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

int strcmp(char *s1,char *s2)
{
while(*s1++==*s2++)
;
return (*s1-*s2);

On sucess return 0, else -1;
}

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

Sure does, my version below.


#include <stdio.h>
#include <stdlib.h>

int main(int argc, char* argv[])
{
char *a;
char *b;

int i;

if (argc !=3)
{
printf ("Incomplete args\n");
exit(-1);
}

a = argv[1];
b = argv[2];

for (i=0;(*a|| *b); i++)
{
if (*a != *b)
{
printf ("Differ at %d, letters are %c, %c\n", i, *a, *b);
exit(-2);
}
a++;
b++;
}
printf("No differences\n");
}

- Srujan December 25, 2012 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 2 vote

#include<stdio.h>
int comp(char *s1,char *s2){
while((*s1)!='\0'&&(*s2)!='\0'){
if(*s1!=*s2) return *s1-*s2;
s1++;
s2++;
}
if(*s1==*s2) return 0;
else return *s1-*s2;


}
int main(){

if(comp("kunje","kunjedfsv dfbvdfbg")==0)printf("same");
else printf("diff");
system("pause");
return 0;
}

- Kunj Bihari Meena December 28, 2012 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

#include<stdio.h>

int strcompare(char *s1,char *s2)
{
int j=0;
int d=0;
while(s1[j]==s2[j]&&(s1[j]!='\0'&&s2[j]!='\0'))
{
printf("%c %c\n",s1[j],s2[j]);
d=1;
j=j+1;
}
if(s1[j]!=s2[j])
{
printf("%c %c\n",s1[j],s2[j]);
d=0;
}
return d;
}

int main(int argc,char **argv)
{
int c=0;
if(argc!=3)
{
printf("Enter two strings for comaprision\n");
return;
}
printf("%s %s %s\n",argv[0],argv[1],argv[2]);
c=strcompare(argv[1],argv[2]);
if(c)
printf("The strings are equal:%d\n",c);
else
printf("The strings are not equal\n");
return 0;
}

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

#include<stdio.h>
#include<string.h>
int main()
{

char s1[200],s2[200];
int flag=0,i;
printf("enter strings ");
scanf("%s %s",s1,s2);
for(i=0;i<strlen(s1);i++)
{
if(s1[i]==s2[i])
{
flag=1;
}
else
{
flag=0;
break;
}
}
printf("\n string is %d \n",flag);

- surajnit.40 January 06, 2013 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

int cmp(char *first,char *second)
{int tmp=1;
for(;*first && tmp;tmp=(*first==*second),first++,second++);
return tmp;
}

- DHEERAJ KUMAR January 07, 2013 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

int strcomp(const char* s1 , const char* s2)
{
	while( *s1 == *s2 && *s1 != 0 ){	
	
		s1++;
		s2++;					
	} 	

	return *s1 - *s2;
}

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

int cmp(char *str1, char *str2)
{
	if(*str1!='\0' || *str2!='\0')
	{
		if (*str1>*str2)
			return 1;
		else if (*str1<*str2)
			return -1;
		else
		{
			str1++;
			str2++;
			cmp(str1,str2);
		}
	}
	else
		return 0;
}

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

int xstrcmp(const char *p,const char *q)
{
	while(*p++==*q++ && *p);
	return *(--p)-*(--q);
}

- kathrotiyanimesh July 05, 2013 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

#include<iostream>
using namespace std;
int comp(char *t,char *s)
{
while(*s||*t)
{
if(*s==*t)
{
s++;
t++;
}
else
return(*s-*t);
}
return 0;
}
int main()
{
char s[20],t[20];
cin>>s;
cin>>t;
int k=comp(t,s);
if(k)
cout<<"Not Same :"<<k;
else
cout<<"Same :"<<k;
}

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

Here Its my code.....simplest one.


#include<stdio.h>
#include<conio.h>
#include<string.h>
int c=0;
int strc(int,char *,char *);
int main()
{
char str1[]={"ratnakar pratap singh"};
char str2[]={"ratnakar pretap singh"};
char *s1,*s2;
s1=str1;
s2=str2;
int x=strlen(str1);
int c=strc(x,s1,s2);
if(c==1)
{ printf("strings are equal");
}
else
{ printf("no");}
getch();
return 0;

}
int strc(int x,char *s1,char *s2)
{
while((*s1)!='\0'&&(*s2)!='\0')
{
if(*s1==*s2)
{ c++;
}
s1++;
s2++;
}
if(c==x)
{
return 1;
}



}

- Ratnakar Pratap Singh August 28, 2013 | Flag Reply


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