Softchoice Interview Question for Software Engineer / Developers






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

No output
But why i dont know
if change intializer change to d=0,then it will give output.

- Anonymouse March 06, 2011 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

Because sizeof is defined as "unsigned int". So a comparison between -1 & sizeof, -1 will be promoted to a unsigned quantity. As a result of which -1 becomes greater then 7.

- Mike March 06, 2011 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

d+1 can guarantee array's subscript is not a negative number.

- Anonymous February 24, 2012 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 votes

d+1 can guarantee array's subscript is not a negative number.

- Anonymous February 24, 2012 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 vote

the sign bit of the signed integer will become the most significant bit for the unsigned int, hence it changes into a very big number

- airfang613 March 09, 2011 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

any integer is automatically converetd to unsigned int (see ritchi page no:197)
suppose int size is 2 bytes
-1=1111111111111111
5=0000000000000101
so when -1 is compared with 5 it converted to unsigned(1111111111111111)2^15-1
which is greater than 5..
thats why no output

- Sachin Gupta B.tech MNNIT,allahabad @2008 June 08, 2011 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

If this is the case ....... then why is

for(i=-1;i<5;i++)
printf("Hello World \n");

giving output ??

- Seth June 30, 2011 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 votes

It depends what type i is being declared as.

Instead of the macro TOTAL_ELEMENTS, replace it with an interger variable like:

int j =5;
 and d <= j, it would work. Since the result of macro is unsigned, its type casted (to unsigned int).

- Krish June 30, 2011 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 vote

the output should be 23,since "array" is a pointr with size 2byte,now array[0] is integer with size 2 byte.. aftr preprocessing the d in for loop is compared with -1,it will run loop for 1 time,hence array[0] that is 23 will be printed..

- rockstar June 03, 2012 | 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