Cisco Systems Interview Question for Software Engineer / Developers






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

Answer is Positive, when an unsigned is used in arithmatic with signed the signed is upgraded to unsigned and result is unsigned.

- Prasad May 10, 2010 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

Actually, the conversion rules are

a) Convert to the larger type.
b) In case of equal size prefer usigned over signed.

You can verify this by changing the declaration of int b to int64_t b. The output would now say Negative.

- Jasmeet Bagga May 11, 2010 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 votes

In addition, I remember that all short, char, unsigned short, unsigned char are promoted to int or unsigned int. This means in

unsigned short + signed int

the int will be promoted to unsigned

- koppie644 November 22, 2013 | Flag
Comment hidden because of low score. Click to expand.
1
of 1 vote

correct me if i am wrong.

majority of the arithmetic operation and comparison operator are upgraded from signed to unsigned (for balancing the assembly instruction)

- siddharam.s.t@gmail.com January 17, 2012 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

If we check

if(a+b == -9)
printf("Hello");

in this case hello is printed. Can anyone explain?

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

coz at binary level -9 and (unsigned)a+b are same had it been a+b>-9 then it will give some other result since then -9 is treated as signed while a+b as unsigned

- think August 11, 2012 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 votes

void main() {
unsigned int a = 10;
int b = -19;
printf("%u",a+b);
getch();
}


can someone explain y the o/p is 4294967287

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

within printf the first thing within quotes get printed there is no %d %s in printf..
dont give anything only copy paste the printf then also same output.

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

That is because signed value is converted into and unsigned, as we know -ve values in c are saved in 2's complement format, and when 2's complement of a negative is considered as unsigned it will become a big +ve number(ex -1 is value when considered as unsigned, its value is 2^32-1(assuming int size is 4 bytes) ). so -19 as unsigned is big positive number, according to your it should be 4294967277.

- Malavya October 28, 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