Broadsoft Interview Question for Solutions Architects


Country: India
Interview Type: In-Person




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

The code which I'm writing below is same as the question.

printf(&unix["\0c%set\012"],(unix)["chak"]+"Trick"-0x67);
printf(&1["\0c%set\012"],(1)["chak"]+"Trick"-0x67);
printf(&1["\0c%set\012"],(1)["chak"]+"Trick"-0x67);
printf(&1["\0c%set"],("chak")[1]+"Trick"-0x67);
printf("c%set",'h'+"Trick"-0x67);
printf("c%set",1+"Trick");
printf("c%set","rick");

So, ultimately, it prints cricket.

- Hasit Bhatt January 08, 2015 | Flag Reply
Comment hidden because of low score. Click to expand.
1
of 1 vote

hey srk,here it goes like this.
unix is a macro in stdio.h with val 1.
\0 is null
&1["\0c%set\012"]
here 12 is discarded as its after null character string ends at null.
&1["\0c%set\0"]
a string constant is internaly replaced by address.
therefore &1["\0c%set\0"]==&*(address+1)
therefore it finaly drops to c%set

samething for (unix)["chak"]=='h'+"trick"-0x67
ascci val 'h'=0x68-0x67=1+"trick"
1+"trick"="rick"
printf("c %s et","rick");

therefore ans: c rick et

- shreeharsha I April 20, 2015 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

crikcet

- Srinivasa Prasad January 08, 2015 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

how cricket?

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

Hello Harshit, Kindly explain how it is print criket. Step by step .

- srk March 21, 2015 | 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