Adobe Interview Question for Developer Program Engineers


Country: India
Interview Type: In-Person




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

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

int my_atoi(char *s)
{
	int i,num=0,sign=1;

	for(i=0;s[i];i++)
        {
                if(s[i]==' ')
                        continue;
                else if(s[i]=='-') sign=-1;
                else break;
        }
        
        for(;s[i] && s[i]>='0' && s[i]<='9';i++)
                num=num*10 + s[i]-'0';
        return num*sign;
}

int main()
{
	char s[]="-12a4";

	printf("%d %d",atoi(s),my_atoi(s));

	return 0;
}

ideone.com/QiIS3

- Aashish July 03, 2012 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

correct but "--12" will return 0.
So in the 1st check of '-' just insert a 'break' statement in it.

- Psycho September 25, 2012 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 vote

/*atoi is a function in the C programming language that converts a string into an integer numerical representation. 
atoi stands for ASCII to integer. It is included in the C standard library header file stdlib.h. Its prototype is as follows:*/

//       Working code

//INPUT : 24 83 0 2
//OUTPUT : 24 83 0 2


#include<stdio.h>
#include<string.h>
int atoi(int K[10],char string[30])
{
    int j=0,i=0,temp=0;
    while(string[i]!='\0')
    {
        temp=0;
        while(string[i]!=' ' && string[i]!='\0')
            temp=temp*10 + (string[i++]-'0') ;
        if(string[i]==' ')
            i++;
        K[j++]=temp;
    }
return j;
}


int main()
{
    char string[30];
    int i,a,A[10];
    printf("\nEnter String : ");
    gets(string);
    a=atoi(A,string);
    printf("\nIntegers are : ");
    for(i=0;i<a;i++)
        printf("%d ",A[i]);
    printf("\n");
return 0;
}

- niraj.nijju July 03, 2012 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

Haven't compiled the code, typing it here only.

int atoi(char *str)
{
	int n = 0;
	int i=0;
	while(str[i])
	{
		n *= 10;
		n += str[i] - '0';
	}
	return n;
}

- varun July 11, 2013 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

increment i in while loop ;
i++;

- rajh May 31, 2014 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 vote

You could certainly see your skills within the work you write. The world hopes for more passionate writers like you who arent afraid to say how they believe. Always follow your heart. bagbfdkecddagcba

- Smitha70 April 01, 2015 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

#include<stdio.h>
#include<stdlib.h>
void main()
{
printf("$$$");
}

- Anonymous July 29, 2017 | 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