Amazon Interview Question for Testing / Quality Assurances






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

//To reverse a string without using inbuilt function

for(i=0;string[i]!='\0';i++);
n=i;
for(i=n-1;i>=0;i--)
reverse[i]=string[i];

- Ayesha September 26, 2012 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

#include <iostream>
#include <cmath>

using namespace std;

void ReverseStringAndNumber(string str, int num)
{
	// String first
	int n = str.length();
	char temp;

	for(int i = 0; i < n / 2; i++)
	{
		temp = str[n-i-1];
		str[n-i-1] = str[i];
		str[i] = temp;
	}

	cout << str.c_str() << endl;

	// Number
	int rem = 0;

	while(num>0)
	{
	
		rem = (rem * 10) + (num % 10);

		num = num / 10;

	}
	
	cout << rem << endl;
}

void main()
{
	ReverseStringAndNumber("canku", 21302341);
}

- cac September 21, 2010 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

void reversestringnumber(char str[],int num)
{
int len;
in i,j,k,second=0;
char temp;
len = strlen(str);
for(i=0,j=len-1;i<j;i++,j--)
{
temp=str[i];
str[i]=str[j];
str[j]=temp;
}
while(num)
{
second=second*10+num%10;
num=num/10;
}
printf("%s %d",str,second);
}

- geeks July 07, 2011 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

Perl code to reverse the string

use POSIX; # for using floor function

chomp($str= <STDIN>);
@string = split ('',$str); # splitter will come first

$len=@string; # length of array

print "Array Length = $len ";

$n=floor((@string)/2);

for($i = 0 ; $i < $n ; $i++) # necessary to use $ with all variable
{
$temp=$string[$i];
$string[$i]=$string[$len-$i-1];
$string[$len-$i-1]=$temp;
}

$string = join ('',@string);
print "reversed string is :- ".$string ."\n";

www udzial com
Udzial Means Share

- Gaurav Khurana April 21, 2014 | 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